def test_script(self, execute_manager): # The test script should execute the standard Django test # command with any apps given as its arguments. test.main('cheeseshop.development', 'spamm', 'eggs') # We only care about the arguments given to execute_manager self.assertEqual(execute_manager.call_args[1], {'argv': ['test', 'test', 'spamm', 'eggs']})
def test_deeply_nested_settings(self, execute_manager): # Settings files can be more than two levels deep. We need to # make sure the test script can properly import those. To # demonstrate this we need to add another level to our # sys.modules entries. settings = mock.sentinel.SettingsModule nce = mock.sentinel.NCE nce.development = settings sys.modules['cheeseshop'].nce = nce sys.modules['cheeseshop.nce'] = nce sys.modules['cheeseshop.nce.development'] = settings test.main('cheeseshop.nce.development', 'tilsit', 'stilton') self.assertEqual(execute_manager.call_args[0], (settings,))
def test_settings_error(self, sys_exit): # When the settings file cannot be imported the test runner # wil exit with a message and a specific exit code. test.main('cheeseshop.tilsit', 'stilton') self.assertEqual(sys_exit.call_args, ((1,), {}))