Skip to content

Commit

Permalink
test_django_setup_sequence: test that apps are not loaded in project …
Browse files Browse the repository at this point in the history
…pytest_configure

Basically the test from
#538.
  • Loading branch information
blueyed committed Jul 26, 2018
1 parent 4acdfc2 commit 683a88d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_django_settings_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,23 @@ def test_anything():
print('TEST: populating=%r,ready=%r' % (populating, apps.ready))
""")

django_testdir.makeconftest('''
def pytest_configure():
import django.apps
assert not django.apps.apps.ready, 'django.setup() was not called'
print("pytest_configure")
''')

result = django_testdir.runpytest_subprocess('-s', '--tb=line')
result.stdout.fnmatch_lines(['*IMPORT: populating=True,ready=False*'])
result.stdout.fnmatch_lines(['*READY(): populating=True*'])
if django.VERSION < (2, 0):
result.stdout.fnmatch_lines(['*TEST: populating=False,ready=True*'])
else:
result.stdout.fnmatch_lines(['*TEST: populating=True,ready=True*'])
result.stdout.fnmatch_lines(['pytest_configure'])
assert result.ret == 0


Expand Down

0 comments on commit 683a88d

Please sign in to comment.