https://pantsbuild.org/ logo
#general
Title
# general
e

eager-dress-66405

08/23/2021, 6:05 PM
Is there a way to specify pytest plugins below the root level? I'm working in a codebase with a lot of django code, but also plenty non django code. If I put
Copy code
[pytest]
pytest_plugins.add = [
     "pytest-django",
in my
pants.toml
all the non django tests complain about not finding django settings
h

hundreds-father-404

08/23/2021, 6:09 PM
Probably best to add as an explicit dependency in that case to the tests that need it:
Copy code
python_tests(dependencies=["3rdparty/python:pytest-django"])
If that's getting too tedious, you could add a lightweight macro `django_tests`: https://www.pantsbuild.org/docs/macros. With the downside of a new symbol / some indirection
e

eager-dress-66405

08/23/2021, 6:45 PM
I think my complaint might have been preemptive. It was picking up plugins from a
pyproject.toml
file. Thanks~