diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py
index 7244086..cea7056 100644
a
|
b
|
from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm,
|
19 | 19 | SetPasswordForm, PasswordResetForm) |
20 | 20 | |
21 | 21 | |
| 22 | @override_settings( |
| 23 | USE_TZ=False, |
| 24 | LANGUAGES=(('en', 'English'),), |
| 25 | LANGUAGE_CODE='en', |
| 26 | TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),) |
| 27 | ) |
22 | 28 | class AuthViewsTestCase(TestCase): |
23 | 29 | """ |
24 | 30 | Helper base class for all the follow test cases. |
… |
… |
class AuthViewsTestCase(TestCase):
|
26 | 32 | fixtures = ['authtestdata.json'] |
27 | 33 | urls = 'django.contrib.auth.tests.urls' |
28 | 34 | |
29 | | def setUp(self): |
30 | | self.old_LANGUAGES = settings.LANGUAGES |
31 | | self.old_LANGUAGE_CODE = settings.LANGUAGE_CODE |
32 | | settings.LANGUAGES = (('en', 'English'),) |
33 | | settings.LANGUAGE_CODE = 'en' |
34 | | self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS |
35 | | settings.TEMPLATE_DIRS = ( |
36 | | os.path.join(os.path.dirname(__file__), 'templates'), |
37 | | ) |
38 | | |
39 | | def tearDown(self): |
40 | | settings.LANGUAGES = self.old_LANGUAGES |
41 | | settings.LANGUAGE_CODE = self.old_LANGUAGE_CODE |
42 | | settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS |
43 | | |
44 | 35 | def login(self, password='password'): |
45 | 36 | response = self.client.post('/login/', { |
46 | 37 | 'username': 'testclient', |
… |
… |
class AuthViewsTestCase(TestCase):
|
53 | 44 | def assertContainsEscaped(self, response, text, **kwargs): |
54 | 45 | return self.assertContains(response, escape(force_unicode(text)), **kwargs) |
55 | 46 | |
56 | | AuthViewsTestCase = override_settings(USE_TZ=False)(AuthViewsTestCase) |
57 | | |
58 | 47 | |
59 | 48 | class AuthViewNamedURLTests(AuthViewsTestCase): |
60 | 49 | urls = 'django.contrib.auth.urls' |
diff --git a/django/test/signals.py b/django/test/signals.py
index 01d5581..08393f5 100644
a
|
b
|
|
1 | 1 | from django.conf import settings |
2 | 2 | from django.db import connections |
3 | | from django.dispatch import Signal |
| 3 | from django.dispatch import Signal, receiver |
4 | 4 | |
5 | 5 | template_rendered = Signal(providing_args=["template", "context"]) |
6 | 6 | |
7 | 7 | setting_changed = Signal(providing_args=["setting", "value"]) |
8 | 8 | |
| 9 | @receiver(setting_changed) |
9 | 10 | def update_connections_time_zone(**kwargs): |
10 | 11 | if kwargs['setting'] == 'USE_TZ' and settings.TIME_ZONE != 'UTC': |
11 | 12 | USE_TZ, TIME_ZONE = kwargs['value'], settings.TIME_ZONE |
… |
… |
def update_connections_time_zone(**kwargs):
|
20 | 21 | if tz_sql: |
21 | 22 | conn.cursor().execute(tz_sql, [tz]) |
22 | 23 | |
23 | | setting_changed.connect(update_connections_time_zone) |
| 24 | @receiver(setting_changed) |
| 25 | def change_default_language(**kwargs): |
| 26 | if kwargs['setting'] == 'LANGUAGE_CODE': |
| 27 | from django.utils.translation import trans_real |
| 28 | trans_real._default = None |