Fix a check_framework test so it doesn't fail when TEST_RUNNER is set (e.g. on CI).

This commit is contained in:
Carl Meyer 2014-01-20 21:08:02 -07:00
parent 6070a5d6a6
commit fb862c875e
1 changed files with 7 additions and 3 deletions

View File

@ -94,9 +94,12 @@ class Django_1_6_0_CompatibilityChecks(TestCase):
self.assertEqual(errors, []) self.assertEqual(errors, [])
def test_test_runner_not_set_explicitly(self): def test_test_runner_not_set_explicitly(self):
# If TEST_RUNNER was set explicitly, temporarily pretend it wasn't
test_runner_overridden = False
if 'TEST_RUNNER' in settings._wrapped._explicit_settings:
test_runner_overridden = True
settings._wrapped._explicit_settings.remove('TEST_RUNNER')
# We remove some settings to make this look like a project generated under Django 1.5. # We remove some settings to make this look like a project generated under Django 1.5.
old_test_runner = settings._wrapped.TEST_RUNNER
del settings._wrapped.TEST_RUNNER
settings._wrapped._explicit_settings.add('MANAGERS') settings._wrapped._explicit_settings.add('MANAGERS')
settings._wrapped._explicit_settings.add('ADMINS') settings._wrapped._explicit_settings.add('ADMINS')
try: try:
@ -116,7 +119,8 @@ class Django_1_6_0_CompatibilityChecks(TestCase):
self.assertEqual(errors, expected) self.assertEqual(errors, expected)
finally: finally:
# Restore settings value # Restore settings value
settings._wrapped.TEST_RUNNER = old_test_runner if test_runner_overridden:
settings._wrapped._explicit_settings.add('TEST_RUNNER')
settings._wrapped._explicit_settings.remove('MANAGERS') settings._wrapped._explicit_settings.remove('MANAGERS')
settings._wrapped._explicit_settings.remove('ADMINS') settings._wrapped._explicit_settings.remove('ADMINS')