diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py
index a75ef61..735e95b 100644
a
|
b
|
|
1 | | from datetime import date |
| 1 | from datetime import date, timedelta |
2 | 2 | from django.conf import settings |
3 | 3 | from django.utils.http import int_to_base36, base36_to_int |
4 | 4 | from django.utils.crypto import constant_time_compare, salted_hmac |
… |
… |
class PasswordResetTokenGenerator(object):
|
52 | 52 | # invalid as soon as it is used. |
53 | 53 | # We limit the hash to 20 chars to keep URL short |
54 | 54 | key_salt = "django.contrib.auth.tokens.PasswordResetTokenGenerator" |
| 55 | |
| 56 | # Ensure consistent timestamps across DB backends |
| 57 | last_login = user.last_login - timedelta(microseconds=user.last_login.microsecond) |
| 58 | |
55 | 59 | value = (unicode(user.id) + user.password + |
56 | | unicode(user.last_login) + unicode(timestamp)) |
| 60 | unicode(last_login) + unicode(timestamp)) |
57 | 61 | hash = salted_hmac(key_salt, value).hexdigest()[::2] |
58 | 62 | return "%s-%s" % (ts_b36, hash) |
59 | 63 | |
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index 7b0e30f..0fe20ec 100644
a
|
b
|
from __future__ import with_statement
|
5 | 5 | import sys |
6 | 6 | import os |
7 | 7 | import gzip |
| 8 | import warnings |
8 | 9 | import zipfile |
9 | 10 | from optparse import make_option |
| 11 | import MySQLdb |
10 | 12 | |
11 | 13 | from django.conf import settings |
12 | 14 | from django.core import serializers |
… |
… |
class Command(BaseCommand):
|
179 | 181 | loaded_objects_in_fixture += 1 |
180 | 182 | models.add(obj.object.__class__) |
181 | 183 | try: |
182 | | obj.save(using=using) |
183 | | except (DatabaseError, IntegrityError), e: |
| 184 | with warnings.catch_warnings(): |
| 185 | warnings.filterwarnings('error', category=MySQLdb.Warning) |
| 186 | obj.save(using=using) |
| 187 | except (DatabaseError, IntegrityError, Warning), e: |
184 | 188 | msg = "Could not load %(app_label)s.%(object_name)s(pk=%(pk)s): %(error_msg)s" % { |
185 | 189 | 'app_label': obj.object._meta.app_label, |
186 | 190 | 'object_name': obj.object._meta.object_name, |
diff --git a/tests/modeltests/fixtures/tests.py b/tests/modeltests/fixtures/tests.py
index 54ce470..46d231f 100644
a
|
b
|
class FixtureLoadingTests(TestCase):
|
263 | 263 | new_io = StringIO.StringIO() |
264 | 264 | management.call_command('loaddata', 'invalid.json', verbosity=0, stderr=new_io, commit=False) |
265 | 265 | output = new_io.getvalue().strip().split('\n') |
266 | | self.assertRegexpMatches(output[-1], "IntegrityError: Could not load fixtures.Article\(pk=1\): .*$") |
| 266 | self.assertRegexpMatches(output[-1], "(IntegrityError|Warning): Could not load fixtures.Article\(pk=1\): .*$") |
267 | 267 | |
268 | 268 | def test_loading_using(self): |
269 | 269 | # Load db fixtures 1 and 2. These will load using the 'default' database identifier explicitly |
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
index 8580e36..b85f5d3 100644
a
|
b
|
class ManageAlternateSettings(AdminScriptTestCase):
|
864 | 864 | "alternate: manage.py builtin commands work with settings provided as argument" |
865 | 865 | args = ['sqlall','--settings=alternate_settings', 'admin_scripts'] |
866 | 866 | out, err = self.run_manage(args) |
867 | | self.assertOutput(out, 'CREATE TABLE "admin_scripts_article"') |
| 867 | self.assertRegexpMatches(out, 'CREATE TABLE (`|")admin_scripts_article(`|")') |
868 | 868 | self.assertNoOutput(err) |
869 | 869 | |
870 | 870 | def test_builtin_with_environment(self): |
871 | 871 | "alternate: manage.py builtin commands work if settings are provided in the environment" |
872 | 872 | args = ['sqlall','admin_scripts'] |
873 | 873 | out, err = self.run_manage(args,'alternate_settings') |
874 | | self.assertOutput(out, 'CREATE TABLE "admin_scripts_article"') |
| 874 | self.assertRegexpMatches(out, 'CREATE TABLE (`|")admin_scripts_article(`|")') |
875 | 875 | self.assertNoOutput(err) |
876 | 876 | |
877 | 877 | def test_builtin_with_bad_settings(self): |
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index fc69d9c..6180b49 100644
a
|
b
|
from django.utils.translation import (ugettext, ugettext_lazy, activate,
|
21 | 21 | deactivate, gettext_lazy, pgettext, npgettext, to_locale, |
22 | 22 | get_language_info, get_language, get_language_from_request) |
23 | 23 | |
| 24 | # Keep as a * import because of conditional imports in .commands.tests |
| 25 | from .commands.tests import * |
24 | 26 | |
25 | | from .commands.tests import NoWrapExtractorTests, IgnoredExtractorTests, MessageCompilationTests, PoFileTests, BasicExtractorTests, JavascriptExtractorTests, CopyPluralFormsExtractorTests, SymlinkExtractorTests, ExtractorTests |
26 | 27 | from .contenttypes.tests import ContentTypeTests |
27 | 28 | from .forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm |
28 | 29 | from .models import Company, TestModel |
diff --git a/tests/regressiontests/multiple_database/tests.py b/tests/regressiontests/multiple_database/tests.py
index 741cba4..b8fab2e 100644
a
|
b
|
from .models import Book, Person, Pet, Review, UserProfile
|
17 | 17 | class QueryTestCase(TestCase): |
18 | 18 | multi_db = True |
19 | 19 | |
| 20 | def setUp(self): |
| 21 | # Disable constraint checking |
| 22 | for connection_name in connections: |
| 23 | connection = connections[connection_name] |
| 24 | connection.disable_constraint_checking() |
| 25 | |
| 26 | def tearDown(self): |
| 27 | # Re-enable constraint checking |
| 28 | for connection_name in connections: |
| 29 | connection = connections[connection_name] |
| 30 | connection.enable_constraint_checking() |
| 31 | |
20 | 32 | def test_db_selection(self): |
21 | 33 | "Check that querysets will use the default database by default" |
22 | 34 | self.assertEqual(Book.objects.db, DEFAULT_DB_ALIAS) |
… |
… |
class RouterTestCase(TestCase):
|
976 | 988 | self.old_routers = router.routers |
977 | 989 | router.routers = [TestRouter()] |
978 | 990 | |
| 991 | # Disable constraint checking |
| 992 | for connection_name in connections: |
| 993 | connection = connections[connection_name] |
| 994 | connection.disable_constraint_checking() |
| 995 | |
979 | 996 | def tearDown(self): |
980 | 997 | # Restore the 'other' database as an independent database |
981 | 998 | router.routers = self.old_routers |
982 | 999 | |
| 1000 | # Re-enable constraint checking |
| 1001 | for connection_name in connections: |
| 1002 | connection = connections[connection_name] |
| 1003 | connection.enable_constraint_checking() |
| 1004 | |
983 | 1005 | def test_db_selection(self): |
984 | 1006 | "Check that querysets obey the router for db suggestions" |
985 | 1007 | self.assertEqual(Book.objects.db, 'other') |
… |
… |
class SignalTests(TestCase):
|
1695 | 1717 | def setUp(self): |
1696 | 1718 | self.old_routers = router.routers |
1697 | 1719 | |
| 1720 | # Disable constraint checking |
| 1721 | for connection_name in connections: |
| 1722 | connection = connections[connection_name] |
| 1723 | connection.disable_constraint_checking() |
| 1724 | |
1698 | 1725 | def tearDown(self): |
1699 | 1726 | router.routers = self.old_routers |
1700 | 1727 | |
| 1728 | # Re-enable constraint checking |
| 1729 | for connection_name in connections: |
| 1730 | connection = connections[connection_name] |
| 1731 | connection.enable_constraint_checking() |
| 1732 | |
1701 | 1733 | def _write_to_other(self): |
1702 | 1734 | "Sends all writes to 'other'." |
1703 | 1735 | router.routers = [WriteToOtherRouter()] |