Ticket #17744: 17744-1.diff
File 17744-1.diff, 3.9 KB (added by , 12 years ago) |
---|
-
django/test/signals.py
diff --git a/django/test/signals.py b/django/test/signals.py index d140304..a96bdff 100644
a b from django.conf import settings 5 5 from django.db import connections 6 6 from django.dispatch import receiver, Signal 7 7 from django.utils import timezone 8 from django.utils.functional import empty 8 9 9 10 template_rendered = Signal(providing_args=["template", "context"]) 10 11 … … def language_changed(**kwargs): 72 73 trans_real._default = None 73 74 if kwargs['setting'] == 'LOCALE_PATHS': 74 75 trans_real._translations = {} 76 77 @receiver(setting_changed) 78 def file_storage_changed(**kwargs): 79 if kwargs['setting'] in ('MEDIA_ROOT', 'DEFAULT_FILE_STORAGE'): 80 from django.core.files.storage import default_storage 81 default_storage._wrapped = empty -
docs/topics/testing.txt
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index 7c25a8b..f5fd4fe 100644
a b callbacks to clean up and otherwise reset state when settings are changed. 1594 1594 1595 1595 Django itself uses this signal to reset various data: 1596 1596 1597 =========================== ======================== 1598 Overriden settings Data reset 1599 =========================== ======================== 1600 USE_TZ, TIME_ZONE Databases timezone 1601 TEMPLATE_CONTEXT_PROCESSORS Context processors cache 1602 TEMPLATE_LOADERS Template loaders cache 1603 SERIALIZATION_MODULES Serializers cache 1604 LOCALE_PATHS, LANGUAGE_CODE Default translation and loaded translations 1605 =========================== ======================== 1597 ================================ ======================== 1598 Overriden settings Data reset 1599 ================================ ======================== 1600 USE_TZ, TIME_ZONE Databases timezone 1601 TEMPLATE_CONTEXT_PROCESSORS Context processors cache 1602 TEMPLATE_LOADERS Template loaders cache 1603 SERIALIZATION_MODULES Serializers cache 1604 LOCALE_PATHS, LANGUAGE_CODE Default translation and loaded translations 1605 MEDIA_ROOT, DEFAULT_FILE_STORAGE Default file storage 1606 ================================ ======================== 1606 1607 1607 1608 Emptying the test outbox 1608 1609 ~~~~~~~~~~~~~~~~~~~~~~~~ -
tests/regressiontests/staticfiles_tests/tests.py
diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py index 7ecbccc..69e3061 100644
a b from django.template import loader, Context 12 12 from django.conf import settings 13 13 from django.core.cache.backends.base import BaseCache 14 14 from django.core.exceptions import ImproperlyConfigured 15 from django.core.files.storage import default_storage16 15 from django.core.management import call_command 17 16 from django.test import TestCase 18 17 from django.test.utils import override_settings … … class BaseStaticFilesTestCase(object): 48 47 Test case with a couple utility assertions. 49 48 """ 50 49 def setUp(self): 51 # Clear the cached default_storage out, this is because when it first52 # gets accessed (by some other test), it evaluates settings. MEDIA_ROOT,50 # Clear the cached staticfiles_storage out, this is because when it first 51 # gets accessed (by some other test), it evaluates settings.STATIC_ROOT, 53 52 # since we're planning on changing that we need to clear out the cache. 54 default_storage._wrapped = empty55 53 storage.staticfiles_storage._wrapped = empty 56 54 # Clear the cached staticfile finders, so they are reinitialized every 57 55 # run and pick up changes in settings.STATICFILES_DIRS. … … class TestMiscFinder(TestCase): 709 707 """ 710 708 A few misc finder tests. 711 709 """ 712 def setUp(self):713 default_storage._wrapped = empty714 715 710 def test_get_finder(self): 716 711 self.assertIsInstance(finders.get_finder( 717 712 'django.contrib.staticfiles.finders.FileSystemFinder'),