diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-10-23 14:32:54 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-10-23 14:32:54 +0000 |
| commit | 85ef6c09386ec55193dc4ca40251c7c4ca559516 (patch) | |
| tree | 312849b91fdeba7d9c916dd0b7b408cf5f6172a9 /tests | |
| parent | c1b3deedaa647034668e6c0fc0464d9d9608f152 (diff) | |
Fixed #14544 -- Squashed bug in the findstatic command when used with the --first option.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14324 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/staticfiles_tests/tests.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py index 83e41b7e14..316b9c4cae 100644 --- a/tests/regressiontests/staticfiles_tests/tests.py +++ b/tests/regressiontests/staticfiles_tests/tests.py @@ -3,6 +3,7 @@ import shutil import os import sys import posixpath +from StringIO import StringIO from django.test import TestCase from django.conf import settings @@ -134,6 +135,39 @@ class TestDefaults(object): self.assertFileContains('test/file1.txt', 'file1 in the app dir') +class TestFindStatic(BuildStaticTestCase, TestDefaults): + """ + Test ``findstatic`` management command. + """ + def _get_file(self, filepath): + _stdout = sys.stdout + sys.stdout = StringIO() + try: + call_command('findstatic', filepath, all=False, verbosity='0') + sys.stdout.seek(0) + lines = [l.strip() for l in sys.stdout.readlines()] + contents = open(lines[1].strip()).read() + finally: + sys.stdout = _stdout + return contents + + def test_all_files(self): + """ + Test that findstatic returns all candidate files if run without --first. + """ + _stdout = sys.stdout + sys.stdout = StringIO() + try: + call_command('findstatic', 'test/file.txt', verbosity='0') + sys.stdout.seek(0) + lines = [l.strip() for l in sys.stdout.readlines()] + finally: + sys.stdout = _stdout + self.assertEquals(len(lines), 3) # three because there is also the "Found <file> here" line + self.failUnless('project' in lines[1]) + self.failUnless('apps' in lines[2]) + + class TestBuildStatic(BuildStaticTestCase, TestDefaults): """ Test ``collectstatic`` management command. |
