summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2018-04-24 05:04:02 +0200
committerTim Graham <timograham@gmail.com>2018-04-23 23:04:02 -0400
commit3aae43d800a15db308cea0ea69729122c5c1d215 (patch)
tree29ddf3703ba389331fe573a7eb1adefcc2343a8c /tests/staticfiles_tests
parentd1413c5d703c60dfb9e2a418c79b3e4aed32ffac (diff)
Fixed #28973 -- Silenced copying/linking messages in collectstatic's default verbosity.
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/cases.py5
-rw-r--r--tests/staticfiles_tests/test_management.py25
2 files changed, 29 insertions, 1 deletions
diff --git a/tests/staticfiles_tests/cases.py b/tests/staticfiles_tests/cases.py
index 918ec4f99e..d4a48ce714 100644
--- a/tests/staticfiles_tests/cases.py
+++ b/tests/staticfiles_tests/cases.py
@@ -61,6 +61,8 @@ class CollectionTestCase(BaseStaticFilesMixin, SimpleTestCase):
is separated because some test cases need those asserts without
all these tests.
"""
+ run_collectstatic_in_setUp = True
+
def setUp(self):
super().setUp()
temp_dir = tempfile.mkdtemp()
@@ -68,7 +70,8 @@ class CollectionTestCase(BaseStaticFilesMixin, SimpleTestCase):
# rather than as a context manager
self.patched_settings = self.settings(STATIC_ROOT=temp_dir)
self.patched_settings.enable()
- self.run_collectstatic()
+ if self.run_collectstatic_in_setUp:
+ self.run_collectstatic()
# Same comment as in runtests.teardown.
self.addCleanup(shutil.rmtree, temp_dir)
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index 0d115d8596..1472c7a488 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -164,6 +164,31 @@ class TestCollection(TestDefaults, CollectionTestCase):
self.assertFileNotFound('test/CVS')
+class TestCollectionVerbosity(CollectionTestCase):
+ copying_msg = 'Copying '
+ run_collectstatic_in_setUp = False
+ staticfiles_copied_msg = 'static files copied to'
+
+ def test_verbosity_0(self):
+ stdout = StringIO()
+ self.run_collectstatic(verbosity=0, stdout=stdout)
+ self.assertEqual(stdout.getvalue(), '')
+
+ def test_verbosity_1(self):
+ stdout = StringIO()
+ self.run_collectstatic(verbosity=1, stdout=stdout)
+ output = stdout.getvalue()
+ self.assertIn(self.staticfiles_copied_msg, output)
+ self.assertNotIn(self.copying_msg, output)
+
+ def test_verbosity_2(self):
+ stdout = StringIO()
+ self.run_collectstatic(verbosity=2, stdout=stdout)
+ output = stdout.getvalue()
+ self.assertIn(self.staticfiles_copied_msg, output)
+ self.assertIn(self.copying_msg, output)
+
+
class TestCollectionClear(CollectionTestCase):
"""
Test the ``--clear`` option of the ``collectstatic`` management command.