Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Sped up the staticfiles_tests by allowing them to only search a few r…

…elevant directories, rather than every single test application.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14396 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit bc6d7d21023bfdd1dd73ac1ceb370fc18a4d241f 1 parent ccc4902
Alex Gaynor authored
11  tests/regressiontests/staticfiles_tests/tests.py
@@ -26,11 +26,11 @@ def setUp(self):
26 26
         self.old_staticfiles_root = settings.STATICFILES_ROOT
27 27
         self.old_staticfiles_dirs = settings.STATICFILES_DIRS
28 28
         self.old_staticfiles_finders = settings.STATICFILES_FINDERS
29  
-        self.old_installed_apps = settings.INSTALLED_APPS
30 29
         self.old_media_root = settings.MEDIA_ROOT
31 30
         self.old_media_url = settings.MEDIA_URL
32 31
         self.old_admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
33 32
         self.old_debug = settings.DEBUG
  33
+        self.old_installed_apps = settings.INSTALLED_APPS
34 34
 
35 35
         # We have to load these apps to test staticfiles.
36 36
         load_app('regressiontests.staticfiles_tests.apps.test')
@@ -50,6 +50,9 @@ def setUp(self):
50 50
             'django.contrib.staticfiles.finders.AppDirectoriesFinder',
51 51
             'django.contrib.staticfiles.finders.DefaultStorageFinder',
52 52
         )
  53
+        settings.INSTALLED_APPS = [
  54
+            "regressiontests.staticfiles_tests",
  55
+        ]
53 56
 
54 57
     def tearDown(self):
55 58
         settings.DEBUG = self.old_debug
@@ -98,7 +101,11 @@ def run_collectstatic(self, **kwargs):
98 101
     def _get_file(self, filepath):
99 102
         assert filepath, 'filepath is empty.'
100 103
         filepath = os.path.join(settings.STATICFILES_ROOT, filepath)
101  
-        return open(filepath).read()
  104
+        f = open(filepath)
  105
+        try:
  106
+            return f.read()
  107
+        finally:
  108
+            f.close()
102 109
 
103 110
 
104 111
 class TestDefaults(object):

0 notes on commit bc6d7d2

Please sign in to comment.
Something went wrong with that request. Please try again.