def test_main(monkeypatch): from django.core import management def mock_exec(args): return monkeypatch.setattr(management, 'execute_from_command_line', mock_exec) main()
def test_set_env_defaults(self): # backup and remove global environment vars oldenv = copy.copy(os.environ) del os.environ['DJANGO_SETTINGS_MODULE'] del os.environ['DJANGO_CONFIGURATION'] main() self.assertIn('DJANGO_SETTINGS_MODULE', os.environ) self.assertIn('DJANGO_CONFIGURATION', os.environ) self.assertEqual(os.environ['DJANGO_SETTINGS_MODULE'], 'localshop.settings') self.assertEqual(os.environ['DJANGO_CONFIGURATION'], 'Localshop') os.environ = oldenv
def test_args_passed_manager(self): main() manage_mock.assert_called_once_with(['init', '--no-superuser']) manage_instance.execute.assert_called_once_with()
def test_no_args_passed_manager(self): main() manage_mock.assert_called_once_with([]) manage_instance.execute.assert_called_once_with()
#!/usr/bin/env python from localshop.runner import main if __name__ == "__main__": main()