Only way around I found was to explicitly make a t...
# general
g
Only way around I found was to explicitly make a target to define the tests and then use that in the dependency for the distribution target
h
This is not a common use-case, so I'm not sure what I expect to happen...
Did you create a python_sources to own the tests? In addition to a python_tests?
g
Yes but that wouldn’t work either - agreed, I wasn’t keen on it but it seems like conda requires it
h
Can you post the BUILD file that worked as a workaround?
g
Root build file:
Copy code
python_sources(name="src")

python_requirements(name="reqs")

resources(
    name="build_resources",
    sources=["README.md", "LICENSE"],
)

python_distribution(
    name="jsf-dist",
    entry_points={
        "console_scripts": {
            "jsf": "jsf.cli:app"
        },
    },
    dependencies=[
        ":src", 
        ":build_resources", 
        "./tests:tests",
    ],
    long_description_path="README.md",
    provides=python_artifact(
        name="jsf",
        version="0.5.4",
        author="ghandic",
        description="Creates fake JSON files from a JSON schema",
        url="<https://github.com/ghandic/jsf>",
        long_description_content_type="text/markdown",
        classifiers=[
            "Programming Language :: Python :: 3",
            "License :: OSI Approved :: MIT License",
            "Operating System :: OS Independent",
        ],
        keywords=[
            "JSON Schema",
            "Fake data",
            "Test data",
            "Schema",
            "JSON",
            "Faker",
            "Hypothesis",
            "Rapid Prototype",
            "Data contract",
        ],
        zip_safe=True,
        python_requires=">=3.7",
        extras_require={"cli": ["typer>=0.7.0"]}
    ),
)
Notice the
"./tests:tests"
in the dependencies
Tests build file:
Copy code
python_test_utils(
    name="test_utils",
)

files(
    name="tests", 
    sources=["data/*.json", "*.py"]
)

python_tests(
    name="pytest",
    dependencies=[":tests"],
    interpreter_constraints=parametrize(py3=[">=3.7,<4"]),
)
h
Ah, interesting, you had to use a
files()
target.
Glad you found a workaround
It might be worth breaking up that
files()
target into two, one for the .json files and one for the .py files - the
python_tests()
target only needs the former, as its sources= already glob over all the right test files
👍 1
That is a creative solution!