diff options
| author | mlavin <markdlavin@gmail.com> | 2015-01-25 09:53:40 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-02-04 10:53:04 -0500 |
| commit | 2730dad0d7c425f33f1ecc6cec01fdbf1cdd8376 (patch) | |
| tree | a1566dd56349cc7adb54281b622d5b8ad61bbfb9 /tests/staticfiles_tests | |
| parent | 4444ff39a4d8c144f70fcdce08c6ca0abab67bb9 (diff) | |
Fixed #24197 -- Added clearing of staticfiles caches on settings changes during tests
Cleared caching in staticfiles_storage and get_finder when
relevant settings are changed.
Diffstat (limited to 'tests/staticfiles_tests')
| -rw-r--r-- | tests/staticfiles_tests/tests.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/tests/staticfiles_tests/tests.py b/tests/staticfiles_tests/tests.py index 43cee9e636..7715b23f7b 100644 --- a/tests/staticfiles_tests/tests.py +++ b/tests/staticfiles_tests/tests.py @@ -60,14 +60,6 @@ class BaseStaticFilesTestCase(object): Test case with a couple utility assertions. """ def setUp(self): - # Clear the cached staticfiles_storage out, this is because when it first - # gets accessed (by some other test), it evaluates settings.STATIC_ROOT, - # since we're planning on changing that we need to clear out the cache. - storage.staticfiles_storage._wrapped = empty - # Clear the cached staticfile finders, so they are reinitialized every - # run and pick up changes in settings.STATICFILES_DIRS. - finders.get_finder.cache_clear() - self.testfiles_path = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'test') # To make sure SVN doesn't hangs itself with the non-ASCII characters # during checkout, we actually create one file dynamically. @@ -130,15 +122,18 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase): """ def setUp(self): super(BaseCollectionTestCase, self).setUp() - self.old_root = settings.STATIC_ROOT - settings.STATIC_ROOT = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']) + temp_dir = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']) + # Override the STATIC_ROOT for all tests from setUp to tearDown + # rather than as a context manager + self.patched_settings = self.settings(STATIC_ROOT=temp_dir) + self.patched_settings.enable() self.run_collectstatic() # Use our own error handler that can handle .svn dirs on Windows - self.addCleanup(shutil.rmtree, settings.STATIC_ROOT, + self.addCleanup(shutil.rmtree, temp_dir, ignore_errors=True, onerror=rmtree_errorhandler) def tearDown(self): - settings.STATIC_ROOT = self.old_root + self.patched_settings.disable() super(BaseCollectionTestCase, self).tearDown() def run_collectstatic(self, **kwargs): |
