Refs #21230 -- removed direct settings manipulation from staticfile tests
This commit is contained in:
parent
e3a9714ce3
commit
949ee521fa
|
@ -1 +0,0 @@
|
||||||
Test!
|
|
|
@ -6,7 +6,6 @@ import os
|
||||||
import posixpath
|
import posixpath
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from django.template import loader, Context
|
from django.template import loader, Context
|
||||||
|
@ -121,17 +120,13 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase):
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseCollectionTestCase, self).setUp()
|
super(BaseCollectionTestCase, self).setUp()
|
||||||
self.old_root = settings.STATIC_ROOT
|
if not os.path.exists(settings.STATIC_ROOT):
|
||||||
settings.STATIC_ROOT = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
|
os.mkdir(settings.STATIC_ROOT)
|
||||||
self.run_collectstatic()
|
self.run_collectstatic()
|
||||||
# Use our own error handler that can handle .svn dirs on Windows
|
# Use our own error handler that can handle .svn dirs on Windows
|
||||||
self.addCleanup(shutil.rmtree, settings.STATIC_ROOT,
|
self.addCleanup(shutil.rmtree, settings.STATIC_ROOT,
|
||||||
ignore_errors=True, onerror=rmtree_errorhandler)
|
ignore_errors=True, onerror=rmtree_errorhandler)
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
settings.STATIC_ROOT = self.old_root
|
|
||||||
super(BaseCollectionTestCase, self).tearDown()
|
|
||||||
|
|
||||||
def run_collectstatic(self, **kwargs):
|
def run_collectstatic(self, **kwargs):
|
||||||
call_command('collectstatic', interactive=False, verbosity='0',
|
call_command('collectstatic', interactive=False, verbosity='0',
|
||||||
ignore_patterns=['*.ignoreme'], **kwargs)
|
ignore_patterns=['*.ignoreme'], **kwargs)
|
||||||
|
@ -754,14 +749,11 @@ class TestServeStatic(StaticFilesTestCase):
|
||||||
self.assertEqual(self._response(filepath).status_code, 404)
|
self.assertEqual(self._response(filepath).status_code, 404)
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(DEBUG=False)
|
||||||
class TestServeDisabled(TestServeStatic):
|
class TestServeDisabled(TestServeStatic):
|
||||||
"""
|
"""
|
||||||
Test serving static files disabled when DEBUG is False.
|
Test serving static files disabled when DEBUG is False.
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
|
||||||
super(TestServeDisabled, self).setUp()
|
|
||||||
settings.DEBUG = False
|
|
||||||
|
|
||||||
def test_disabled_serving(self):
|
def test_disabled_serving(self):
|
||||||
self.assertFileNotFound('test.txt')
|
self.assertFileNotFound('test.txt')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue