summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-01-01 13:54:25 -0500
committerTim Graham <timograham@gmail.com>2015-01-01 13:57:52 -0500
commitb9feec959b9dfc08513607c9046fb38c5b8f7e8a (patch)
tree05cdcf12208ba077a65e54b420b215cbf8cb0e4d
parent40a85043576f6d163a2a05721a4b2710261fc4f5 (diff)
Fixed #23700 -- Fixed non-deterministic static files test failures on Windows.
This partially reverts commit 949ee521fab106b44218c30577eb55f0097d39cd refs #21230.
-rw-r--r--tests/staticfiles_tests/project/site_media/static/testfile.txt1
-rw-r--r--tests/staticfiles_tests/tests.py9
2 files changed, 8 insertions, 2 deletions
diff --git a/tests/staticfiles_tests/project/site_media/static/testfile.txt b/tests/staticfiles_tests/project/site_media/static/testfile.txt
new file mode 100644
index 0000000000..4d92dbe1ad
--- /dev/null
+++ b/tests/staticfiles_tests/project/site_media/static/testfile.txt
@@ -0,0 +1 @@
+Test! \ No newline at end of file
diff --git a/tests/staticfiles_tests/tests.py b/tests/staticfiles_tests/tests.py
index ffce4d047b..1d5ccfc075 100644
--- a/tests/staticfiles_tests/tests.py
+++ b/tests/staticfiles_tests/tests.py
@@ -6,6 +6,7 @@ import os
import posixpath
import shutil
import sys
+import tempfile
import unittest
from django.template import Context, Template
@@ -129,13 +130,17 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase):
"""
def setUp(self):
super(BaseCollectionTestCase, self).setUp()
- if not os.path.exists(settings.STATIC_ROOT):
- os.mkdir(settings.STATIC_ROOT)
+ self.old_root = settings.STATIC_ROOT
+ settings.STATIC_ROOT = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
self.run_collectstatic()
# Use our own error handler that can handle .svn dirs on Windows
self.addCleanup(shutil.rmtree, settings.STATIC_ROOT,
ignore_errors=True, onerror=rmtree_errorhandler)
+ def tearDown(self):
+ settings.STATIC_ROOT = self.old_root
+ super(BaseCollectionTestCase, self).tearDown()
+
def run_collectstatic(self, **kwargs):
call_command('collectstatic', interactive=False, verbosity=0,
ignore_patterns=['*.ignoreme'], **kwargs)