mirror of https://github.com/django/django.git
Ensure that the staticfiles tests use the MEDIA_ROOT they intended, also use a more approrpiate datastructure in collectstatic.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14401 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
03b12ae2cf
commit
aa951eb8ea
|
@ -39,9 +39,9 @@ class Command(NoArgsCommand):
|
||||||
if options['use_default_ignore_patterns']:
|
if options['use_default_ignore_patterns']:
|
||||||
ignore_patterns += ['CVS', '.*', '*~']
|
ignore_patterns += ['CVS', '.*', '*~']
|
||||||
ignore_patterns = list(set(ignore_patterns))
|
ignore_patterns = list(set(ignore_patterns))
|
||||||
self.copied_files = []
|
self.copied_files = set()
|
||||||
self.symlinked_files = []
|
self.symlinked_files = set()
|
||||||
self.unmodified_files = []
|
self.unmodified_files = set()
|
||||||
self.destination_storage = get_storage_class(settings.STATICFILES_STORAGE)()
|
self.destination_storage = get_storage_class(settings.STATICFILES_STORAGE)()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -124,14 +124,14 @@ Type 'yes' to continue, or 'no' to cancel: """)
|
||||||
# storage doesn't support ``modified_time`` or failed.
|
# storage doesn't support ``modified_time`` or failed.
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
destination_is_link= os.path.islink(
|
destination_is_link = os.path.islink(
|
||||||
self.destination_storage.path(destination))
|
self.destination_storage.path(destination))
|
||||||
if destination_last_modified == source_last_modified:
|
if destination_last_modified == source_last_modified:
|
||||||
if (not symlink and not destination_is_link):
|
if (not symlink and not destination_is_link):
|
||||||
if verbosity >= 2:
|
if verbosity >= 2:
|
||||||
self.stdout.write("Skipping '%s' (not modified)\n"
|
self.stdout.write("Skipping '%s' (not modified)\n"
|
||||||
% destination)
|
% destination)
|
||||||
self.unmodified_files.append(destination)
|
self.unmodified_files.add(destination)
|
||||||
return False
|
return False
|
||||||
if dry_run:
|
if dry_run:
|
||||||
if verbosity >= 2:
|
if verbosity >= 2:
|
||||||
|
@ -157,7 +157,7 @@ Type 'yes' to continue, or 'no' to cancel: """)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
os.symlink(source_path, destination_path)
|
os.symlink(source_path, destination_path)
|
||||||
self.symlinked_files.append(destination)
|
self.symlinked_files.add(destination)
|
||||||
else:
|
else:
|
||||||
if dry_run:
|
if dry_run:
|
||||||
if verbosity >= 1:
|
if verbosity >= 1:
|
||||||
|
@ -180,5 +180,5 @@ Type 'yes' to continue, or 'no' to cancel: """)
|
||||||
if verbosity >= 1:
|
if verbosity >= 1:
|
||||||
self.stdout.write("Copying %s to %s\n"
|
self.stdout.write("Copying %s to %s\n"
|
||||||
% (source_path, destination))
|
% (source_path, destination))
|
||||||
self.copied_files.append(destination)
|
self.copied_files.add(destination)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -7,12 +7,13 @@ from StringIO import StringIO
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.contrib.staticfiles import finders, storage
|
||||||
|
from django.core.files.storage import default_storage
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from django.db.models.loading import load_app
|
from django.db.models.loading import load_app
|
||||||
from django.template import Template, Context
|
from django.template import Template, Context
|
||||||
|
|
||||||
from django.contrib.staticfiles import finders, storage
|
|
||||||
|
|
||||||
TEST_ROOT = os.path.dirname(__file__)
|
TEST_ROOT = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
@ -54,6 +55,11 @@ class StaticFilesTestCase(TestCase):
|
||||||
"regressiontests.staticfiles_tests",
|
"regressiontests.staticfiles_tests",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Clear the cached default_storage out, this is because when it first
|
||||||
|
# gets accessed (by some other test), it evaluates settings.MEDIA_ROOT,
|
||||||
|
# since we're planning on changing that we need to clear out the cache.
|
||||||
|
default_storage._wrapped = None
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
settings.DEBUG = self.old_debug
|
settings.DEBUG = self.old_debug
|
||||||
settings.MEDIA_ROOT = self.old_media_root
|
settings.MEDIA_ROOT = self.old_media_root
|
||||||
|
|
Loading…
Reference in New Issue