File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -354,10 +354,13 @@ def finalize(self):
354
354
355
355
356
356
@pytest .yield_fixture ()
357
- def settings ():
357
+ def settings (request ):
358
358
"""A Django settings object which restores changes after the testrun"""
359
359
skip_if_no_django ()
360
360
361
+ if 'transactional_db' in request .fixturenames :
362
+ request .getfixturevalue ('transactional_db' )
363
+
361
364
wrapper = SettingsWrapper ()
362
365
yield wrapper
363
366
wrapper .finalize ()
Original file line number Diff line number Diff line change @@ -316,6 +316,30 @@ def test_set_non_existent(settings):
316
316
]
317
317
)
318
318
319
+ def test_transactional_db_order (self , django_testdir ):
320
+ django_testdir .create_test_module (
321
+ """
322
+ import pytest
323
+
324
+ from django.conf import settings as django_settings
325
+ from django.db.models.signals import post_migrate
326
+
327
+ @pytest.fixture
328
+ def check_settings_in_post_migrate(settings, transactional_db):
329
+ def receiver(sender, **kwargs):
330
+ assert not hasattr(django_settings, 'TRANSIENT_SETTING')
331
+
332
+ post_migrate.connect(receiver, weak=False)
333
+
334
+ def test_set_non_existent(settings, check_settings_in_post_migrate):
335
+ settings.TRANSIENT_SETTING = 1
336
+ """
337
+ )
338
+
339
+ result = django_testdir .runpytest_subprocess ("-v" )
340
+ assert result .ret == 0
341
+ result .stdout .fnmatch_lines (["*test_set_non_existent PASSED*" ])
342
+
319
343
320
344
class TestLiveServer :
321
345
def test_settings_before (self ):
You can’t perform that action at this time.
0 commit comments