diff options
| author | django-bot <ops@djangoproject.com> | 2022-02-03 20:24:19 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-07 20:37:05 +0100 |
| commit | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch) | |
| tree | f0506b668a013d0063e5fba3dbf4863b466713ba /tests/staticfiles_tests/test_liveserver.py | |
| parent | f68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff) | |
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/staticfiles_tests/test_liveserver.py')
| -rw-r--r-- | tests/staticfiles_tests/test_liveserver.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/tests/staticfiles_tests/test_liveserver.py b/tests/staticfiles_tests/test_liveserver.py index 38d1513c9a..214459555d 100644 --- a/tests/staticfiles_tests/test_liveserver.py +++ b/tests/staticfiles_tests/test_liveserver.py @@ -13,10 +13,10 @@ from django.test import modify_settings, override_settings TEST_ROOT = os.path.dirname(__file__) TEST_SETTINGS = { - 'MEDIA_URL': 'media/', - 'STATIC_URL': 'static/', - 'MEDIA_ROOT': os.path.join(TEST_ROOT, 'project', 'site_media', 'media'), - 'STATIC_ROOT': os.path.join(TEST_ROOT, 'project', 'site_media', 'static'), + "MEDIA_URL": "media/", + "STATIC_URL": "static/", + "MEDIA_ROOT": os.path.join(TEST_ROOT, "project", "site_media", "media"), + "STATIC_ROOT": os.path.join(TEST_ROOT, "project", "site_media", "static"), } @@ -34,17 +34,16 @@ class LiveServerBase(StaticLiveServerTestCase): class StaticLiveServerChecks(LiveServerBase): - @classmethod def setUpClass(cls): # If contrib.staticfiles isn't configured properly, the exception # should bubble up to the main thread. - old_STATIC_URL = TEST_SETTINGS['STATIC_URL'] - TEST_SETTINGS['STATIC_URL'] = None + old_STATIC_URL = TEST_SETTINGS["STATIC_URL"] + TEST_SETTINGS["STATIC_URL"] = None try: cls.raises_exception() finally: - TEST_SETTINGS['STATIC_URL'] = old_STATIC_URL + TEST_SETTINGS["STATIC_URL"] = old_STATIC_URL @classmethod def tearDownClass(cls): @@ -60,7 +59,7 @@ class StaticLiveServerChecks(LiveServerBase): # app without having set the required STATIC_URL setting.") pass else: - raise Exception('setUpClass() should have raised an exception.') + raise Exception("setUpClass() should have raised an exception.") def test_test_test(self): # Intentionally empty method so that the test is picked up by the @@ -69,16 +68,15 @@ class StaticLiveServerChecks(LiveServerBase): class StaticLiveServerView(LiveServerBase): - def urlopen(self, url): return urlopen(self.live_server_url + url) # The test is going to access a static file stored in this application. - @modify_settings(INSTALLED_APPS={'append': 'staticfiles_tests.apps.test'}) + @modify_settings(INSTALLED_APPS={"append": "staticfiles_tests.apps.test"}) def test_collectstatic_emulation(self): """ StaticLiveServerTestCase use of staticfiles' serve() allows it to discover app's static assets without having to collectstatic first. """ - with self.urlopen('/static/test/file.txt') as f: - self.assertEqual(f.read().rstrip(b'\r\n'), b'In static directory.') + with self.urlopen("/static/test/file.txt") as f: + self.assertEqual(f.read().rstrip(b"\r\n"), b"In static directory.") |
