django-configurations/tests/setup_test.py
Daniel Hahler 8f199eb40c _setup: do not call django.setup() if settings are configured already
Without this, using `configurations.setup()` after Django has been setup
already re-triggers the logging configuration, which then causes e.g.
pytest's caplog to not work anymore.
2018-08-16 17:04:50 +02:00

17 lines
368 B
Python

"""Used by tests to ensure logging is kept when calling setup() twice."""
try:
from unittest import mock
except ImportError:
from mock import mock
import configurations
print('setup_1')
configurations.setup()
with mock.patch('django.setup', side_effect=Exception('setup called twice')):
print('setup_2')
configurations.setup()
print('setup_done')