Navigation Menu

Skip to content

Commit

Permalink
Changed a bit the strategy used to test staticfiles finders so they c…
Browse files Browse the repository at this point in the history
…an cope with even more differences in case of paths under Windows. Refs #14961

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16285 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
ramiro committed May 27, 2011
1 parent 407f62f commit d071604
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/regressiontests/staticfiles_tests/tests.py
Expand Up @@ -17,7 +17,7 @@
from django.utils._os import rmtree_errorhandler


TEST_ROOT = os.path.normcase(os.path.dirname(__file__))
TEST_ROOT = os.path.dirname(__file__)


class StaticFilesTestCase(TestCase):
Expand Down Expand Up @@ -352,15 +352,23 @@ def test_serve_admin_media(self):

class FinderTestCase(object):
"""
Base finder test mixin
Base finder test mixin.
On Windows, sometimes the case of the path we ask the finders for and the
path(s) they find can differ. Compare them using os.path.normcase() to
avoid false negatives.
"""
def test_find_first(self):
src, dst = self.find_first
self.assertEqual(self.finder.find(src), dst)
found = self.finder.find(src)
self.assertEqual(os.path.normcase(found), os.path.normcase(dst))

def test_find_all(self):
src, dst = self.find_all
self.assertEqual(self.finder.find(src, all=True), dst)
found = self.finder.find(src, all=True)
found = [os.path.normcase(f) for f in found]
dst = [os.path.normcase(d) for d in dst]
self.assertEqual(found, dst)


class TestFileSystemFinder(StaticFilesTestCase, FinderTestCase):
Expand Down

0 comments on commit d071604

Please sign in to comment.