https://pantsbuild.org/ logo
b

big-fall-51153

05/04/2021, 7:52 PM
๐Ÿงตresponses please to not detract from the current convo - I'm looking into a temporary workaround for this issue, specifically I need to set
DJANGO_SETTINGS_MODULE
for specific directories / per-
python_tests
. Maybe someone has a solution for this? I've made some attempts with pytest hooks to no avail
h

hundreds-father-404

05/04/2021, 7:55 PM
cc @happy-kitchen-89482, does this ring a bell? You have more Django experience than me
p

polite-garden-50641

05/04/2021, 7:56 PM
We do that by having a conftest.py file and those call to an common conftest.py file which does common things.
๐Ÿ™Œ 1
Screen Shot 2021-05-04 at 12.56.29 PM.png
h

hundreds-father-404

05/04/2021, 7:57 PM
See https://www.pantsbuild.org/v2.5/docs/python-test-goal#conftestpy for more info on how Pants hooks into conftest.py
p

polite-garden-50641

05/04/2021, 7:58 PM
so ^^ this is the conftest at the module level.
h

happy-kitchen-89482

05/04/2021, 7:58 PM
This indeed ties in to my upcoming DjancoCon EU workshop
p

polite-garden-50641

05/04/2021, 7:58 PM
and then we have the "common" conftest.py (the one imported in the module local conftest.py):
h

happy-kitchen-89482

05/04/2021, 8:00 PM
But yeah, instead of setting DJANGO_SETTINGS_MODULE we use the
pytest_configure()
hook in a
conftest.py
in the relevant dir
and we have that hook call
settings.configure(...)
p

polite-garden-50641

05/04/2021, 8:01 PM
looks roughly like this (I redacted a bunch of things, but I think the general idea is understandable):
b

big-fall-51153

05/04/2021, 8:03 PM
great, thanks! that helps a lot
๐Ÿ™Œ 1
3 Views