mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-17 06:30:28 +00:00
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.
17 lines
368 B
Python
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')
|