def test_check_compatibility(self): with self.settings(TEST_RUNNER="django.test.runner.DiscoverRunner"): result = base.check_compatibility() self.assertEqual(len(result), 1) self.assertTrue("You have not explicitly set 'TEST_RUNNER'" in result[0]) with self.settings(TEST_RUNNER="myapp.test.CustomRunnner"): self.assertEqual(len(base.check_compatibility()), 0)
def test_check_compatibility_warning(self): # First, we're patching over the ``COMPAT_CHECKS`` with a stub which # will trigger the warning. base.COMPAT_CHECKS = [StubCheckModule()] # Next, we unfortunately have to patch out ``warnings``. old_warnings = base.warnings base.warnings = FakeWarnings() self.assertEqual(len(base.warnings._warnings), 0) with self.settings(TEST_RUNNER="myapp.test.CustomRunnner"): self.assertEqual(len(base.check_compatibility()), 0) self.assertEqual(len(base.warnings._warnings), 1) self.assertTrue("The 'StubCheckModule' module lacks a 'run_checks'" in base.warnings._warnings[0]) # Restore the ``warnings``. base.warnings = old_warnings
def handle_noargs(self, **options): for message in check_compatibility(): warnings.warn(message)