Author: jezdez
Date: 2010-10-23 09:32:54 -0500 (Sat, 23 Oct 2010)
New Revision: 14324
Modified:
django/trunk/django/contrib/staticfiles/management/commands/findstatic.py
django/trunk/tests/regressiontests/staticfiles_tests/tests.py
Log:
Fixed #14544 -- Squashed bug in the findstatic command when used with the
--first option.
Modified:
django/trunk/django/contrib/staticfiles/management/commands/findstatic.py
===================================================================
--- django/trunk/django/contrib/staticfiles/management/commands/findstatic.py
2010-10-23 14:32:20 UTC (rev 14323)
+++ django/trunk/django/contrib/staticfiles/management/commands/findstatic.py
2010-10-23 14:32:54 UTC (rev 14324)
@@ -17,6 +17,8 @@
verbosity = int(options.get('verbosity', 1))
result = finders.find(path, all=options['all'])
if result:
+ if not isinstance(result, (list, tuple)):
+ result = [result]
output = '\n '.join((os.path.realpath(path) for path in result))
self.stdout.write("Found %r here:\n %s\n" % (path, output))
else:
Modified: django/trunk/tests/regressiontests/staticfiles_tests/tests.py
===================================================================
--- django/trunk/tests/regressiontests/staticfiles_tests/tests.py
2010-10-23 14:32:20 UTC (rev 14323)
+++ django/trunk/tests/regressiontests/staticfiles_tests/tests.py
2010-10-23 14:32:54 UTC (rev 14324)
@@ -3,6 +3,7 @@
import os
import sys
import posixpath
+from StringIO import StringIO
from django.test import TestCase
from django.conf import settings
@@ -134,6 +135,39 @@
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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.