pytest-django icon indicating copy to clipboard operation
pytest-django copied to clipboard

Early "python-paths" setting?

Open pakal opened this issue 6 years ago • 3 comments
trafficstars

I know about the pytest-python path plugin, but I'd like much earlier pythonpaths to be setup by pytest-django, so that it can find my early hook (which applies patches before django.setup()).

It looks like a simpler solution, for now, than making the "django.setup()" call configurable in pytest conf. In an early hook (before conftest.py files search and django;setup() loading), uers have all power to customize environment as they please, including replacing django.setup by something else..

Does it sound right that I attempt a PR on a setting like "python_paths_early = your/path/apps your/path/libs"? Or am I missing some aspects of the architecture?

pakal avatar Sep 23 '19 10:09 pakal

I've opened a PR for a first look at how it might look: https://github.com/pytest-dev/pytest-django/pull/768

pakal avatar Oct 07 '19 18:10 pakal

I've updated the PR to latest master (https://github.com/pytest-dev/pytest-django/pull/768)

pakal avatar Jul 04 '20 18:07 pakal

pytest-pythonpaths loads paths as early as it can, but even that doesn't work for my needs actually: the "-p" option of Pytest is loaded veryyyyy early in the pytest workflow, so I don't get a chance to modify pythonpath so that it can load my custom plugin (used to patch django.setup() before pytest-django does it).

So it seems the proper way to go would be new pytest-django settings to customize the setup step, as proposed in issue #723

pakal avatar Jul 28 '20 11:07 pakal