Loading tests/staticfiles_tests/cases.py +6 −9 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ from django.utils.encoding import force_text from .settings import TEST_SETTINGS class BaseStaticFilesTestCase(object): class BaseStaticFilesMixin(object): """ Test case with a couple utility assertions. """ Loading Loading @@ -52,11 +52,12 @@ class BaseStaticFilesTestCase(object): @override_settings(**TEST_SETTINGS) class StaticFilesTestCase(BaseStaticFilesTestCase, SimpleTestCase): class StaticFilesTestCase(BaseStaticFilesMixin, SimpleTestCase): pass class BaseCollectionTestCase(BaseStaticFilesTestCase): @override_settings(**TEST_SETTINGS) class CollectionTestCase(BaseStaticFilesMixin, SimpleTestCase): """ Tests shared by all file finding features (collectstatic, findstatic, and static serve view). Loading @@ -66,7 +67,7 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase): all these tests. """ def setUp(self): super(BaseCollectionTestCase, self).setUp() super(CollectionTestCase, self).setUp() temp_dir = tempfile.mkdtemp() # Override the STATIC_ROOT for all tests from setUp to tearDown # rather than as a context manager Loading @@ -78,7 +79,7 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase): def tearDown(self): self.patched_settings.disable() super(BaseCollectionTestCase, self).tearDown() super(CollectionTestCase, self).tearDown() def run_collectstatic(self, **kwargs): call_command('collectstatic', interactive=False, verbosity=0, Loading @@ -91,10 +92,6 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase): return f.read() class CollectionTestCase(BaseCollectionTestCase, StaticFilesTestCase): pass class TestDefaults(object): """ A few standard test cases. Loading tests/staticfiles_tests/settings.py +0 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ from django.utils._os import upath TEST_ROOT = os.path.dirname(upath(__file__)) TEST_SETTINGS = { 'DEBUG': True, 'MEDIA_URL': '/media/', 'STATIC_URL': '/static/', 'MEDIA_ROOT': os.path.join(TEST_ROOT, 'project', 'site_media', 'media'), Loading tests/staticfiles_tests/test_finders.py +4 −4 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ from .cases import StaticFilesTestCase from .settings import TEST_ROOT class FinderTestCase(object): class TestFinders(object): """ Base finder test mixin. Loading @@ -32,7 +32,7 @@ class FinderTestCase(object): self.assertEqual(found, dst) class TestFileSystemFinder(StaticFilesTestCase, FinderTestCase): class TestFileSystemFinder(TestFinders, StaticFilesTestCase): """ Test FileSystemFinder. """ Loading @@ -44,7 +44,7 @@ class TestFileSystemFinder(StaticFilesTestCase, FinderTestCase): self.find_all = (os.path.join('test', 'file.txt'), [test_file_path]) class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase): class TestAppDirectoriesFinder(TestFinders, StaticFilesTestCase): """ Test AppDirectoriesFinder. """ Loading @@ -56,7 +56,7 @@ class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase): self.find_all = (os.path.join('test', 'file1.txt'), [test_file_path]) class TestDefaultStorageFinder(StaticFilesTestCase, FinderTestCase): class TestDefaultStorageFinder(TestFinders, StaticFilesTestCase): """ Test DefaultStorageFinder. """ Loading tests/staticfiles_tests/test_management.py +6 −6 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ class TestNoFilesCreated(object): self.assertEqual(os.listdir(settings.STATIC_ROOT), []) class TestFindStatic(CollectionTestCase, TestDefaults): class TestFindStatic(TestDefaults, CollectionTestCase): """ Test ``findstatic`` management command. """ Loading Loading @@ -134,7 +134,7 @@ class TestCollectionHelpSubcommand(AdminScriptTestCase): self.assertNoOutput(err) class TestCollection(CollectionTestCase, TestDefaults): class TestCollection(TestDefaults, CollectionTestCase): """ Test ``collectstatic`` management command. """ Loading Loading @@ -176,7 +176,7 @@ class TestCollectionClear(CollectionTestCase): self.assertFileNotFound('cleared.txt') class TestCollectionExcludeNoDefaultIgnore(CollectionTestCase, TestDefaults): class TestCollectionExcludeNoDefaultIgnore(TestDefaults, CollectionTestCase): """ Test ``--exclude-dirs`` and ``--no-default-ignore`` options of the ``collectstatic`` management command. Loading @@ -195,7 +195,7 @@ class TestCollectionExcludeNoDefaultIgnore(CollectionTestCase, TestDefaults): self.assertFileContains('test/CVS', 'should be ignored') class TestCollectionDryRun(CollectionTestCase, TestNoFilesCreated): class TestCollectionDryRun(TestNoFilesCreated, CollectionTestCase): """ Test ``--dry-run`` option for ``collectstatic`` management command. """ Loading Loading @@ -316,7 +316,7 @@ class TestCollectionOverwriteWarning(CollectionTestCase): @override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.DummyStorage') class TestCollectionNonLocalStorage(CollectionTestCase, TestNoFilesCreated): class TestCollectionNonLocalStorage(TestNoFilesCreated, CollectionTestCase): """ Tests for #15035 """ Loading @@ -324,7 +324,7 @@ class TestCollectionNonLocalStorage(CollectionTestCase, TestNoFilesCreated): @unittest.skipUnless(symlinks_supported(), "Must be able to symlink to run this test.") class TestCollectionLinks(CollectionTestCase, TestDefaults): class TestCollectionLinks(TestDefaults, CollectionTestCase): """ Test ``--link`` option for ``collectstatic`` management command. Loading tests/staticfiles_tests/test_storage.py +13 −27 Original line number Diff line number Diff line Loading @@ -12,14 +12,12 @@ from django.contrib.staticfiles.management.commands.collectstatic import \ Command as CollectstaticCommand from django.core.cache.backends.base import BaseCache from django.core.management import call_command from django.test import SimpleTestCase, override_settings from django.test import override_settings from django.utils import six from django.utils.encoding import force_text from .cases import ( BaseCollectionTestCase, BaseStaticFilesTestCase, StaticFilesTestCase, ) from .settings import TEST_ROOT, TEST_SETTINGS from .cases import CollectionTestCase from .settings import TEST_ROOT def hashed_file_path(test, path): Loading Loading @@ -199,14 +197,10 @@ class TestHashedFiles(object): self.assertEqual("Post-processing 'faulty.css' failed!\n\n", err.getvalue()) # we set DEBUG to False here since the template tag wouldn't work otherwise @override_settings(**dict( TEST_SETTINGS, @override_settings( STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage', DEBUG=False, )) class TestCollectionCachedStorage(TestHashedFiles, BaseCollectionTestCase, BaseStaticFilesTestCase, SimpleTestCase): ) class TestCollectionCachedStorage(TestHashedFiles, CollectionTestCase): """ Tests for the Cache busting storage """ Loading Loading @@ -243,14 +237,10 @@ class TestCollectionCachedStorage(TestHashedFiles, BaseCollectionTestCase, self.assertEqual(cache_key, 'staticfiles:821ea71ef36f95b3922a77f7364670e7') # we set DEBUG to False here since the template tag wouldn't work otherwise @override_settings(**dict( TEST_SETTINGS, @override_settings( STATICFILES_STORAGE='django.contrib.staticfiles.storage.ManifestStaticFilesStorage', DEBUG=False, )) class TestCollectionManifestStorage(TestHashedFiles, BaseCollectionTestCase, BaseStaticFilesTestCase, SimpleTestCase): ) class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase): """ Tests for the Cache busting storage """ Loading Loading @@ -321,14 +311,10 @@ class TestCollectionManifestStorage(TestHashedFiles, BaseCollectionTestCase, self.assertNotIn(cleared_file_name, manifest_content) # we set DEBUG to False here since the template tag wouldn't work otherwise @override_settings(**dict( TEST_SETTINGS, @override_settings( STATICFILES_STORAGE='staticfiles_tests.storage.SimpleCachedStaticFilesStorage', DEBUG=False, )) class TestCollectionSimpleCachedStorage(BaseCollectionTestCase, BaseStaticFilesTestCase, SimpleTestCase): ) class TestCollectionSimpleCachedStorage(CollectionTestCase): """ Tests for the Cache busting storage """ Loading Loading @@ -364,7 +350,7 @@ class CustomStaticFilesStorage(storage.StaticFilesStorage): @unittest.skipIf(sys.platform.startswith('win'), "Windows only partially supports chmod.") class TestStaticFilePermissions(BaseCollectionTestCase, StaticFilesTestCase): class TestStaticFilePermissions(CollectionTestCase): command_params = { 'interactive': False, Loading Loading
tests/staticfiles_tests/cases.py +6 −9 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ from django.utils.encoding import force_text from .settings import TEST_SETTINGS class BaseStaticFilesTestCase(object): class BaseStaticFilesMixin(object): """ Test case with a couple utility assertions. """ Loading Loading @@ -52,11 +52,12 @@ class BaseStaticFilesTestCase(object): @override_settings(**TEST_SETTINGS) class StaticFilesTestCase(BaseStaticFilesTestCase, SimpleTestCase): class StaticFilesTestCase(BaseStaticFilesMixin, SimpleTestCase): pass class BaseCollectionTestCase(BaseStaticFilesTestCase): @override_settings(**TEST_SETTINGS) class CollectionTestCase(BaseStaticFilesMixin, SimpleTestCase): """ Tests shared by all file finding features (collectstatic, findstatic, and static serve view). Loading @@ -66,7 +67,7 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase): all these tests. """ def setUp(self): super(BaseCollectionTestCase, self).setUp() super(CollectionTestCase, self).setUp() temp_dir = tempfile.mkdtemp() # Override the STATIC_ROOT for all tests from setUp to tearDown # rather than as a context manager Loading @@ -78,7 +79,7 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase): def tearDown(self): self.patched_settings.disable() super(BaseCollectionTestCase, self).tearDown() super(CollectionTestCase, self).tearDown() def run_collectstatic(self, **kwargs): call_command('collectstatic', interactive=False, verbosity=0, Loading @@ -91,10 +92,6 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase): return f.read() class CollectionTestCase(BaseCollectionTestCase, StaticFilesTestCase): pass class TestDefaults(object): """ A few standard test cases. Loading
tests/staticfiles_tests/settings.py +0 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ from django.utils._os import upath TEST_ROOT = os.path.dirname(upath(__file__)) TEST_SETTINGS = { 'DEBUG': True, 'MEDIA_URL': '/media/', 'STATIC_URL': '/static/', 'MEDIA_ROOT': os.path.join(TEST_ROOT, 'project', 'site_media', 'media'), Loading
tests/staticfiles_tests/test_finders.py +4 −4 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ from .cases import StaticFilesTestCase from .settings import TEST_ROOT class FinderTestCase(object): class TestFinders(object): """ Base finder test mixin. Loading @@ -32,7 +32,7 @@ class FinderTestCase(object): self.assertEqual(found, dst) class TestFileSystemFinder(StaticFilesTestCase, FinderTestCase): class TestFileSystemFinder(TestFinders, StaticFilesTestCase): """ Test FileSystemFinder. """ Loading @@ -44,7 +44,7 @@ class TestFileSystemFinder(StaticFilesTestCase, FinderTestCase): self.find_all = (os.path.join('test', 'file.txt'), [test_file_path]) class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase): class TestAppDirectoriesFinder(TestFinders, StaticFilesTestCase): """ Test AppDirectoriesFinder. """ Loading @@ -56,7 +56,7 @@ class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase): self.find_all = (os.path.join('test', 'file1.txt'), [test_file_path]) class TestDefaultStorageFinder(StaticFilesTestCase, FinderTestCase): class TestDefaultStorageFinder(TestFinders, StaticFilesTestCase): """ Test DefaultStorageFinder. """ Loading
tests/staticfiles_tests/test_management.py +6 −6 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ class TestNoFilesCreated(object): self.assertEqual(os.listdir(settings.STATIC_ROOT), []) class TestFindStatic(CollectionTestCase, TestDefaults): class TestFindStatic(TestDefaults, CollectionTestCase): """ Test ``findstatic`` management command. """ Loading Loading @@ -134,7 +134,7 @@ class TestCollectionHelpSubcommand(AdminScriptTestCase): self.assertNoOutput(err) class TestCollection(CollectionTestCase, TestDefaults): class TestCollection(TestDefaults, CollectionTestCase): """ Test ``collectstatic`` management command. """ Loading Loading @@ -176,7 +176,7 @@ class TestCollectionClear(CollectionTestCase): self.assertFileNotFound('cleared.txt') class TestCollectionExcludeNoDefaultIgnore(CollectionTestCase, TestDefaults): class TestCollectionExcludeNoDefaultIgnore(TestDefaults, CollectionTestCase): """ Test ``--exclude-dirs`` and ``--no-default-ignore`` options of the ``collectstatic`` management command. Loading @@ -195,7 +195,7 @@ class TestCollectionExcludeNoDefaultIgnore(CollectionTestCase, TestDefaults): self.assertFileContains('test/CVS', 'should be ignored') class TestCollectionDryRun(CollectionTestCase, TestNoFilesCreated): class TestCollectionDryRun(TestNoFilesCreated, CollectionTestCase): """ Test ``--dry-run`` option for ``collectstatic`` management command. """ Loading Loading @@ -316,7 +316,7 @@ class TestCollectionOverwriteWarning(CollectionTestCase): @override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.DummyStorage') class TestCollectionNonLocalStorage(CollectionTestCase, TestNoFilesCreated): class TestCollectionNonLocalStorage(TestNoFilesCreated, CollectionTestCase): """ Tests for #15035 """ Loading @@ -324,7 +324,7 @@ class TestCollectionNonLocalStorage(CollectionTestCase, TestNoFilesCreated): @unittest.skipUnless(symlinks_supported(), "Must be able to symlink to run this test.") class TestCollectionLinks(CollectionTestCase, TestDefaults): class TestCollectionLinks(TestDefaults, CollectionTestCase): """ Test ``--link`` option for ``collectstatic`` management command. Loading
tests/staticfiles_tests/test_storage.py +13 −27 Original line number Diff line number Diff line Loading @@ -12,14 +12,12 @@ from django.contrib.staticfiles.management.commands.collectstatic import \ Command as CollectstaticCommand from django.core.cache.backends.base import BaseCache from django.core.management import call_command from django.test import SimpleTestCase, override_settings from django.test import override_settings from django.utils import six from django.utils.encoding import force_text from .cases import ( BaseCollectionTestCase, BaseStaticFilesTestCase, StaticFilesTestCase, ) from .settings import TEST_ROOT, TEST_SETTINGS from .cases import CollectionTestCase from .settings import TEST_ROOT def hashed_file_path(test, path): Loading Loading @@ -199,14 +197,10 @@ class TestHashedFiles(object): self.assertEqual("Post-processing 'faulty.css' failed!\n\n", err.getvalue()) # we set DEBUG to False here since the template tag wouldn't work otherwise @override_settings(**dict( TEST_SETTINGS, @override_settings( STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage', DEBUG=False, )) class TestCollectionCachedStorage(TestHashedFiles, BaseCollectionTestCase, BaseStaticFilesTestCase, SimpleTestCase): ) class TestCollectionCachedStorage(TestHashedFiles, CollectionTestCase): """ Tests for the Cache busting storage """ Loading Loading @@ -243,14 +237,10 @@ class TestCollectionCachedStorage(TestHashedFiles, BaseCollectionTestCase, self.assertEqual(cache_key, 'staticfiles:821ea71ef36f95b3922a77f7364670e7') # we set DEBUG to False here since the template tag wouldn't work otherwise @override_settings(**dict( TEST_SETTINGS, @override_settings( STATICFILES_STORAGE='django.contrib.staticfiles.storage.ManifestStaticFilesStorage', DEBUG=False, )) class TestCollectionManifestStorage(TestHashedFiles, BaseCollectionTestCase, BaseStaticFilesTestCase, SimpleTestCase): ) class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase): """ Tests for the Cache busting storage """ Loading Loading @@ -321,14 +311,10 @@ class TestCollectionManifestStorage(TestHashedFiles, BaseCollectionTestCase, self.assertNotIn(cleared_file_name, manifest_content) # we set DEBUG to False here since the template tag wouldn't work otherwise @override_settings(**dict( TEST_SETTINGS, @override_settings( STATICFILES_STORAGE='staticfiles_tests.storage.SimpleCachedStaticFilesStorage', DEBUG=False, )) class TestCollectionSimpleCachedStorage(BaseCollectionTestCase, BaseStaticFilesTestCase, SimpleTestCase): ) class TestCollectionSimpleCachedStorage(CollectionTestCase): """ Tests for the Cache busting storage """ Loading Loading @@ -364,7 +350,7 @@ class CustomStaticFilesStorage(storage.StaticFilesStorage): @unittest.skipIf(sys.platform.startswith('win'), "Windows only partially supports chmod.") class TestStaticFilePermissions(BaseCollectionTestCase, StaticFilesTestCase): class TestStaticFilePermissions(CollectionTestCase): command_params = { 'interactive': False, Loading