class NoAdminPageTests(POSERTestCase): urls = 'poser.test_utils.project.noadmin_urls' def setUp(self): admin = 'django.contrib.admin' noadmin_apps = [app for app in settings.INSTALLED_APPS if not app == admin] self._ctx = SettingsOverride(INSTALLED_APPS=noadmin_apps) self._ctx.__enter__() def tearDown(self): self._ctx.__exit__(None, None, None) def test_get_page_from_request_fakeadmin_nopage(self): request = self.get_request('/admin/') page = get_page_from_request(request) self.assertEqual(page, None)
class SettingsOverrideTestCase(POSERTestCase): settings_overrides = {} def _pre_setup(self): self._enter_settings_override() super(SettingsOverrideTestCase, self)._pre_setup() def _enter_settings_override(self): self._settings_ctx_manager = SettingsOverride(**self.settings_overrides) self._settings_ctx_manager.__enter__() def _post_teardown(self): super(SettingsOverrideTestCase, self)._post_teardown() self._exit_settings_override() def _exit_settings_override(self): self._settings_ctx_manager.__exit__(None, None, None)
class SettingsOverrideTestCase(POSERTestCase): settings_overrides = {} def _pre_setup(self): self._enter_settings_override() super(SettingsOverrideTestCase, self)._pre_setup() def _enter_settings_override(self): self._settings_ctx_manager = SettingsOverride( **self.settings_overrides) self._settings_ctx_manager.__enter__() def _post_teardown(self): super(SettingsOverrideTestCase, self)._post_teardown() self._exit_settings_override() def _exit_settings_override(self): self._settings_ctx_manager.__exit__(None, None, None)
class NoAdminPageTests(POSERTestCase): urls = 'poser.test_utils.project.noadmin_urls' def setUp(self): admin = 'django.contrib.admin' noadmin_apps = [ app for app in settings.INSTALLED_APPS if not app == admin ] self._ctx = SettingsOverride(INSTALLED_APPS=noadmin_apps) self._ctx.__enter__() def tearDown(self): self._ctx.__exit__(None, None, None) def test_get_page_from_request_fakeadmin_nopage(self): request = self.get_request('/admin/') page = get_page_from_request(request) self.assertEqual(page, None)