summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests/test_management.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-02-13 18:20:29 +0100
committerClaude Paroz <claude@2xlibre.net>2016-02-23 09:12:12 +0100
commit269b5f262cef88cb595b21a76e707b41ee4ed627 (patch)
tree153b75fab39ae75606390fa0d12a5a6055eb1f41 /tests/staticfiles_tests/test_management.py
parentb46c0ea6c87f006f9ef0ccc5d8c0fa2445fb4156 (diff)
Used call_command return value in staticfiles tests
Refs #26190.
Diffstat (limited to 'tests/staticfiles_tests/test_management.py')
-rw-r--r--tests/staticfiles_tests/test_management.py25
1 files changed, 8 insertions, 17 deletions
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index ed6749b217..4700977666 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -39,21 +39,16 @@ class TestFindStatic(CollectionTestCase, TestDefaults):
Test ``findstatic`` management command.
"""
def _get_file(self, filepath):
- out = six.StringIO()
- call_command('findstatic', filepath, all=False, verbosity=0, stdout=out)
- out.seek(0)
- lines = [l.strip() for l in out.readlines()]
- with codecs.open(force_text(lines[0].strip()), "r", "utf-8") as f:
+ path = call_command('findstatic', filepath, all=False, verbosity=0, stdout=six.StringIO())
+ with codecs.open(force_text(path), "r", "utf-8") as f:
return f.read()
def test_all_files(self):
"""
Test that findstatic returns all candidate files if run without --first and -v1.
"""
- out = six.StringIO()
- call_command('findstatic', 'test/file.txt', verbosity=1, stdout=out)
- out.seek(0)
- lines = [l.strip() for l in out.readlines()]
+ result = call_command('findstatic', 'test/file.txt', verbosity=1, stdout=six.StringIO())
+ lines = [l.strip() for l in result.split('\n')]
self.assertEqual(len(lines), 3) # three because there is also the "Found <file> here" line
self.assertIn('project', force_text(lines[1]))
self.assertIn('apps', force_text(lines[2]))
@@ -62,10 +57,8 @@ class TestFindStatic(CollectionTestCase, TestDefaults):
"""
Test that findstatic returns all candidate files if run without --first and -v0.
"""
- out = six.StringIO()
- call_command('findstatic', 'test/file.txt', verbosity=0, stdout=out)
- out.seek(0)
- lines = [l.strip() for l in out.readlines()]
+ result = call_command('findstatic', 'test/file.txt', verbosity=0, stdout=six.StringIO())
+ lines = [l.strip() for l in result.split('\n')]
self.assertEqual(len(lines), 2)
self.assertIn('project', force_text(lines[0]))
self.assertIn('apps', force_text(lines[1]))
@@ -75,10 +68,8 @@ class TestFindStatic(CollectionTestCase, TestDefaults):
Test that findstatic returns all candidate files if run without --first and -v2.
Also, test that findstatic returns the searched locations with -v2.
"""
- out = six.StringIO()
- call_command('findstatic', 'test/file.txt', verbosity=2, stdout=out)
- out.seek(0)
- lines = [l.strip() for l in out.readlines()]
+ result = call_command('findstatic', 'test/file.txt', verbosity=2, stdout=six.StringIO())
+ lines = [l.strip() for l in result.split('\n')]
self.assertIn('project', force_text(lines[1]))
self.assertIn('apps', force_text(lines[2]))
self.assertIn("Looking in the following locations:", force_text(lines[3]))