Is it possible to do something like ```__defaults...
# general
s
Is it possible to do something like
Copy code
__defaults__(
    {
        "python_test": {
            "dependencies.add": ["path/to/common/fixtures.py"],
        },
    }
)
Using
python_test_utils
is great for a
conftest
but what about a
conftest
for the entire monorepo? (our monorepo is a collection of directories like
{top-level-project}/src
and
{top-level-project}/tests
)
Reading through https://www.pantsbuild.org/dev/docs/using-pants/key-concepts/targets-and-build-files It seems like I ought to be able to do __defaults__( { “python_test”: { “dependencies.add”: [“path/to/common/fixtures.py”], }, }, extend=True ) but that hasn’t been successful
Nope - Still confused
e
As long as you have the appropriate
python_test_utils
targets describing your
conftest.py
files, all
conftest.py
files in the same directory or any parent directory of a
python_test
target should be recognized as dependencies automatically. In other words, there should be no need for what you are trying to do. Can you share what your directory structure and BUILD files look like (or a reduced example)?
s
Thanks @elegant-florist-94385. I ended up just importing shared fixtures into a
conftest
adjacent to the tests that use them. I was able to also get it to work by having a conftest in my root directory with a “pytest_plugin = …“. I think between fighting weird syntax of
__defaults__
and pytest fixture magic I didn’t think clearly enough about what I was actually trying to achieve.
1
e
Key thing to remember is that pytest does a lot of "search the filesystem" type stuff, which doesn't always play nice with dependency inference and sandboxes. If you can get the sandbox filesystem to be correct, it will usually work out