diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-12-31 10:01:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-31 10:01:31 +0100 |
| commit | d88ec42bd0a37340c8477a6f20bf26e58bd84735 (patch) | |
| tree | abd9422f7fb34a19579a74515ce84d9f472cd226 /tests/staticfiles_tests/test_storage.py | |
| parent | 81ccf92f154c6d9eac3e30bac0aa67574d0ace15 (diff) | |
Used addCleanup() in tests where appropriate.
Diffstat (limited to 'tests/staticfiles_tests/test_storage.py')
| -rw-r--r-- | tests/staticfiles_tests/test_storage.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index ea2293ccde..1e537dfe54 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -417,16 +417,15 @@ class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase): with open(self._clear_filename, "w") as f: f.write("to be deleted in one test") - self.patched_settings = self.settings( + patched_settings = self.settings( STATICFILES_DIRS=settings.STATICFILES_DIRS + [temp_dir], ) - self.patched_settings.enable() + patched_settings.enable() + self.addCleanup(patched_settings.disable) self.addCleanup(shutil.rmtree, temp_dir) self._manifest_strict = storage.staticfiles_storage.manifest_strict def tearDown(self): - self.patched_settings.disable() - if os.path.exists(self._clear_filename): os.unlink(self._clear_filename) @@ -702,13 +701,13 @@ class CustomManifestStorage(storage.ManifestStaticFilesStorage): class TestCustomManifestStorage(SimpleTestCase): def setUp(self): - self.manifest_path = Path(tempfile.mkdtemp()) - self.addCleanup(shutil.rmtree, self.manifest_path) + manifest_path = Path(tempfile.mkdtemp()) + self.addCleanup(shutil.rmtree, manifest_path) self.staticfiles_storage = CustomManifestStorage( - manifest_location=self.manifest_path, + manifest_location=manifest_path, ) - self.manifest_file = self.manifest_path / self.staticfiles_storage.manifest_name + self.manifest_file = manifest_path / self.staticfiles_storage.manifest_name # Manifest without paths. self.manifest = {"version": self.staticfiles_storage.manifest_version} with self.manifest_file.open("w") as manifest_file: @@ -762,13 +761,10 @@ class TestStaticFilePermissions(CollectionTestCase): def setUp(self): self.umask = 0o027 - self.old_umask = os.umask(self.umask) + old_umask = os.umask(self.umask) + self.addCleanup(os.umask, old_umask) super().setUp() - def tearDown(self): - os.umask(self.old_umask) - super().tearDown() - # Don't run collectstatic command in this test class. def run_collectstatic(self, **kwargs): pass |
