[TIP] pytest + Django: Where to put the test settings.py?
tinchester at gmail.com
Sun Mar 23 15:44:26 PDT 2014
this little project of mine (https://github.com/Tinche/bower-cache) uses
Django, together with pytest for testing. I use the first layout from
http://pytest.org/latest/goodpractises.html; a separate top-level
directory for tests, and I'd like to keep my test data and the actual
app code separate.
I do, however, need a valid Django settings.py in order to run the
tests. My first instinct was to put it into the tests directory and
refer to it as tests.settings in my pytest.ini, but this doesn't work
unless I make the tests directory a proper Python package (with
__init__.py) which pytest explicitly suggests to avoid. The other option
would be to put it somewhere into the app itself, but then this means
I'm mixing test and normal code, which is something I'm trying to avoid
in the first place.
I was wondering if there was a generally-accepted way of solving this
problem. Any advice from the community would be appreciated. :)
Thanks in advance,
More information about the testing-in-python