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

swift-river-73520

04/03/2023, 10:59 PM
how do people handle
pytest
folders for different subprojects which share
conftest.py
fixtures? Right now I'm putting shared test utilities into a common non-conftest.py module, then having a conftest.py file local to each subproject which imports the utilities and applies the pytest
fixture
wrapper. This seems to work alright and eliminates duplication of the fixture logic, but the fixtures themselves still need to be duplicated to apply the
fixture
wrapper. Feels like I'm probably missing a way to share the actual
conftest.py
between tests in various directories / subprojects
r

refined-addition-53644

04/06/2023, 11:16 AM
I wonder if you can use a
python_test_utils
specific to this shared
conftest
and put explicit dependency on it across subprojects. It still sounds bit icky though. Currently I define subproject specific conftest. We haven’t had use case where we had to share fixtures across multiple sub-projects but i can definitely see this can be the case in future since we have lot of fixtures around mocking aws infra.
s

swift-river-73520

04/06/2023, 6:36 PM
I think all my
python_test
targets would need to include the dependency, which would be a pain. although I could probably abstract that behind a macro. I have lots of data-generation and spark fixtures that get shared so it's a problem I'll be tackling soon. In some ways I kinda like having a subproject-specific conftest that explicitly imports the fixtures it cares about from a shared module.
6 Views