mirror of https://github.com/django/django.git
Merge pull request #28 from akaariai/ticket_18163
Ticket 18163 - use faster password hasher in tests.
This commit is contained in:
commit
b86a00187d
|
@ -1,6 +1,8 @@
|
|||
import hashlib
|
||||
|
||||
from django.dispatch import receiver
|
||||
from django.conf import settings
|
||||
from django.test.signals import setting_changed
|
||||
from django.utils import importlib
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.encoding import smart_str
|
||||
|
@ -14,6 +16,13 @@ UNUSABLE_PASSWORD = '!' # This will never be a valid encoded hash
|
|||
HASHERS = None # lazily loaded from PASSWORD_HASHERS
|
||||
PREFERRED_HASHER = None # defaults to first item in PASSWORD_HASHERS
|
||||
|
||||
@receiver(setting_changed)
|
||||
def reset_hashers(**kwargs):
|
||||
if kwargs['setting'] == 'PASSWORD_HASHERS':
|
||||
global HASHERS, PREFERRED_HASHER
|
||||
HASHERS = None
|
||||
PREFERRED_HASHER = None
|
||||
|
||||
|
||||
def is_password_usable(encoded):
|
||||
return (encoded is not None and encoded != UNUSABLE_PASSWORD)
|
||||
|
|
|
@ -13,6 +13,7 @@ from django.test.utils import override_settings
|
|||
os.path.join(os.path.dirname(__file__), 'templates'),
|
||||
),
|
||||
USE_TZ=False, # required for loading the fixture
|
||||
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
|
||||
)
|
||||
class AuthContextProcessorTests(TestCase):
|
||||
"""
|
||||
|
|
|
@ -11,7 +11,7 @@ from django.utils import translation
|
|||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
||||
@override_settings(USE_TZ=False)
|
||||
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class UserCreationFormTest(TestCase):
|
||||
|
||||
fixtures = ['authtestdata.json']
|
||||
|
@ -77,7 +77,7 @@ class UserCreationFormTest(TestCase):
|
|||
self.assertEqual(repr(u), '<User: jsmith@example.com>')
|
||||
|
||||
|
||||
@override_settings(USE_TZ=False)
|
||||
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AuthenticationFormTest(TestCase):
|
||||
|
||||
fixtures = ['authtestdata.json']
|
||||
|
@ -129,7 +129,7 @@ class AuthenticationFormTest(TestCase):
|
|||
self.assertEqual(form.non_field_errors(), [])
|
||||
|
||||
|
||||
@override_settings(USE_TZ=False)
|
||||
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SetPasswordFormTest(TestCase):
|
||||
|
||||
fixtures = ['authtestdata.json']
|
||||
|
@ -156,7 +156,7 @@ class SetPasswordFormTest(TestCase):
|
|||
self.assertTrue(form.is_valid())
|
||||
|
||||
|
||||
@override_settings(USE_TZ=False)
|
||||
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class PasswordChangeFormTest(TestCase):
|
||||
|
||||
fixtures = ['authtestdata.json']
|
||||
|
@ -204,7 +204,7 @@ class PasswordChangeFormTest(TestCase):
|
|||
['old_password', 'new_password1', 'new_password2'])
|
||||
|
||||
|
||||
@override_settings(USE_TZ=False)
|
||||
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class UserChangeFormTest(TestCase):
|
||||
|
||||
fixtures = ['authtestdata.json']
|
||||
|
@ -251,7 +251,7 @@ class UserChangeFormTest(TestCase):
|
|||
form.as_table()
|
||||
|
||||
|
||||
@override_settings(USE_TZ=False)
|
||||
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class PasswordResetFormTest(TestCase):
|
||||
|
||||
fixtures = ['authtestdata.json']
|
||||
|
|
|
@ -3,7 +3,7 @@ from django.test.utils import override_settings
|
|||
from django.contrib.auth import signals
|
||||
|
||||
|
||||
@override_settings(USE_TZ=False)
|
||||
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SignalTestCase(TestCase):
|
||||
urls = 'django.contrib.auth.tests.urls'
|
||||
fixtures = ['authtestdata.json']
|
||||
|
|
|
@ -27,6 +27,7 @@ from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm,
|
|||
os.path.join(os.path.dirname(__file__), 'templates'),
|
||||
),
|
||||
USE_TZ=False,
|
||||
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
|
||||
)
|
||||
class AuthViewsTestCase(TestCase):
|
||||
"""
|
||||
|
|
|
@ -25,10 +25,11 @@ from __future__ import absolute_import
|
|||
from django.conf import settings
|
||||
from django.core import mail
|
||||
from django.test import Client, TestCase, RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from .views import get_view
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class ClientTest(TestCase):
|
||||
fixtures = ['testdata.json']
|
||||
|
||||
|
|
|
@ -950,7 +950,8 @@ class NewFormsTests(TestCase):
|
|||
self.assertEqual(e.dt, datetime.datetime(2011, 9, 1, 10, 20, 30, tzinfo=UTC))
|
||||
|
||||
|
||||
@override_settings(DATETIME_FORMAT='c', TIME_ZONE='Africa/Nairobi', USE_L10N=False, USE_TZ=True)
|
||||
@override_settings(DATETIME_FORMAT='c', TIME_ZONE='Africa/Nairobi', USE_L10N=False, USE_TZ=True,
|
||||
PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminTests(TestCase):
|
||||
|
||||
urls = 'modeltests.timezones.urls'
|
||||
|
|
|
@ -3,10 +3,12 @@ from __future__ import absolute_import
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.template.response import TemplateResponse
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from .models import Action
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminCustomUrlsTest(TestCase):
|
||||
fixtures = ['users.json', 'actions.json']
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.contrib.admin.helpers import InlineAdminForm
|
|||
from django.contrib.auth.models import User, Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
# local test models
|
||||
from .admin import InnerInline
|
||||
|
@ -13,6 +14,7 @@ from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person,
|
|||
ProfileCollection)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class TestInline(TestCase):
|
||||
urls = "regressiontests.admin_inlines.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -145,6 +147,7 @@ class TestInline(TestCase):
|
|||
'<input id="id_-2-0-name" type="text" class="vTextField" '
|
||||
'name="-2-0-name" maxlength="100" />', html=True)
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class TestInlineMedia(TestCase):
|
||||
urls = "regressiontests.admin_inlines.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -384,6 +387,7 @@ class TestInlinePermissions(TestCase):
|
|||
self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -502,4 +506,4 @@ class SeleniumChromeTests(SeleniumFirefoxTests):
|
|||
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
||||
|
||||
class SeleniumIETests(SeleniumFirefoxTests):
|
||||
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
||||
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
||||
|
|
|
@ -47,6 +47,7 @@ from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount,
|
|||
ERROR_MESSAGE = "Please enter the correct username and password \
|
||||
for a staff account. Note that both fields are case-sensitive."
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewBasicTest(TestCase):
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml',
|
||||
'admin-views-fabrics.xml', 'admin-views-books.xml']
|
||||
|
@ -588,6 +589,7 @@ class AdminViewBasicTest(TestCase):
|
|||
msg='The "change password" link should not be displayed if a user does not have a usable password.')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewFormUrlTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ["admin-views-users.xml"]
|
||||
|
@ -619,6 +621,7 @@ class AdminViewFormUrlTest(TestCase):
|
|||
self.assertTrue('custom_filter_template.html' in [t.name for t in response.templates])
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminJavaScriptTest(TestCase):
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
||||
|
@ -686,6 +689,7 @@ class AdminJavaScriptTest(TestCase):
|
|||
self.assertNotContains(response, 'inlines.min.js')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SaveAsTests(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml','admin-views-person.xml']
|
||||
|
@ -775,6 +779,7 @@ def get_perm(Model, perm):
|
|||
ct = ContentType.objects.get_for_model(Model)
|
||||
return Permission.objects.get(content_type=ct, codename=perm)
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewPermissionsTest(TestCase):
|
||||
"""Tests for Admin Views Permissions."""
|
||||
|
||||
|
@ -1179,6 +1184,7 @@ class AdminViewPermissionsTest(TestCase):
|
|||
self.assertContains(response, 'id="login-form"')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewsNoUrlTest(TestCase):
|
||||
"""Regression test for #17333"""
|
||||
|
||||
|
@ -1210,6 +1216,7 @@ class AdminViewsNoUrlTest(TestCase):
|
|||
self.client.get('/test_admin/admin/logout/')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewDeletedObjectsTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml', 'deleted-objects.xml']
|
||||
|
@ -1326,6 +1333,7 @@ class AdminViewDeletedObjectsTest(TestCase):
|
|||
response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(3))
|
||||
self.assertContains(response, should_contain)
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewStringPrimaryKeyTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml', 'string-primary-key.xml']
|
||||
|
@ -1418,6 +1426,7 @@ class AdminViewStringPrimaryKeyTest(TestCase):
|
|||
self.assertContains(response, should_contain)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SecureViewTests(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -1576,6 +1585,7 @@ class SecureViewTests(TestCase):
|
|||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(response['Location'], 'http://example.com/users/super/')
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewUnicodeTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-unicode.xml']
|
||||
|
@ -1630,6 +1640,7 @@ class AdminViewUnicodeTest(TestCase):
|
|||
self.assertRedirects(response, '/test_admin/admin/admin_views/book/')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewListEditable(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-person.xml']
|
||||
|
@ -2004,6 +2015,7 @@ class AdminViewListEditable(TestCase):
|
|||
self.assertContains(response, '<th><a href="%d/">%d</a></th>' % (story2.id, story2.id), 1)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminSearchTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users', 'multiple-child-classes',
|
||||
|
@ -2051,6 +2063,7 @@ class AdminSearchTest(TestCase):
|
|||
self.assertNotContains(response, "Guido")
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminInheritedInlinesTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml',]
|
||||
|
@ -2137,6 +2150,7 @@ class AdminInheritedInlinesTest(TestCase):
|
|||
self.assertEqual(BarAccount.objects.all()[0].username, "%s-1" % bar_user)
|
||||
self.assertEqual(Persona.objects.all()[0].accounts.count(), 2)
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminActionsTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-actions.xml']
|
||||
|
@ -2355,6 +2369,7 @@ class AdminActionsTest(TestCase):
|
|||
self.assertEqual(response.context["action_form"], None)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class TestCustomChangeList(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -2383,6 +2398,7 @@ class TestCustomChangeList(TestCase):
|
|||
self.assertNotContains(response, 'First Gadget')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class TestInlineNotEditable(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -2401,6 +2417,7 @@ class TestInlineNotEditable(TestCase):
|
|||
response = self.client.get('/test_admin/admin/admin_views/parent/add/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminCustomQuerysetTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -2456,6 +2473,7 @@ class AdminCustomQuerysetTest(TestCase):
|
|||
# Message should contain non-ugly model name. Instance representation is set by model's __unicode__()
|
||||
self.assertContains(response, '<li class="info">The cover letter "John Doe II" was changed successfully.</li>', html=True)
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminInlineFileUploadTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-actions.xml']
|
||||
|
@ -2502,6 +2520,7 @@ class AdminInlineFileUploadTest(TestCase):
|
|||
self.assertTrue(response._container[0].find("Currently:") > -1)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminInlineTests(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -2820,6 +2839,7 @@ class AdminInlineTests(TestCase):
|
|||
self.assertEqual(Category.objects.get(id=4).order, 0)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class NeverCacheTests(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml']
|
||||
|
@ -2893,6 +2913,7 @@ class NeverCacheTests(TestCase):
|
|||
self.assertEqual(get_max_age(response), None)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class PrePopulatedTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -2928,6 +2949,7 @@ class PrePopulatedTest(TestCase):
|
|||
self.assertContains(response, "maxLength: 1000") # instead of 1,000
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
|
@ -3051,6 +3073,7 @@ class SeleniumPrePopulatedIETests(SeleniumPrePopulatedFirefoxTests):
|
|||
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class ReadonlyTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -3124,6 +3147,7 @@ class ReadonlyTest(TestCase):
|
|||
self.assertEquals(response.status_code, 404)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class RawIdFieldsTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -3157,6 +3181,7 @@ class RawIdFieldsTest(TestCase):
|
|||
self.assertContains(response2, "Spain")
|
||||
self.assertNotContains(response2, "England")
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class UserAdminTest(TestCase):
|
||||
"""
|
||||
Tests user CRUD functionality.
|
||||
|
@ -3257,6 +3282,7 @@ class UserAdminTest(TestCase):
|
|||
self.assertEqual(response.context['form_url'], 'pony')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class GroupAdminTest(TestCase):
|
||||
"""
|
||||
Tests group CRUD functionality.
|
||||
|
@ -3288,6 +3314,7 @@ class GroupAdminTest(TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class CSSTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -3321,6 +3348,7 @@ except ImportError:
|
|||
docutils = None
|
||||
|
||||
@unittest.skipUnless(docutils, "no docutils installed.")
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminDocsTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -3363,6 +3391,7 @@ class AdminDocsTest(TestCase):
|
|||
self.assertContains(response, '<li><a href="#built_in-add">add</a></li>', html=True)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class ValidXHTMLTests(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -3386,6 +3415,7 @@ class ValidXHTMLTests(TestCase):
|
|||
self.assertNotContains(response, ' xml:lang=""')
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class DateHierarchyTests(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
@ -3512,6 +3542,7 @@ class DateHierarchyTests(TestCase):
|
|||
self.assert_non_localized_year(response, 2003)
|
||||
self.assert_non_localized_year(response, 2005)
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminCustomSaveRelatedTests(TestCase):
|
||||
"""
|
||||
Ensure that one can easily customize the way related objects are saved.
|
||||
|
@ -3580,6 +3611,7 @@ class AdminCustomSaveRelatedTests(TestCase):
|
|||
self.assertEqual([u'Catherine Stone', u'Paul Stone'], children_names)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminViewLogoutTest(TestCase):
|
||||
urls = "regressiontests.admin_views.urls"
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
|
|
@ -12,6 +12,7 @@ from django.core.files.storage import default_storage
|
|||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.db.models import DateField
|
||||
from django.test import TestCase as DjangoTestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.utils import translation
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.unittest import TestCase
|
||||
|
@ -122,6 +123,7 @@ class AdminFormfieldForDBFieldTests(TestCase):
|
|||
self.assertFormfield(models.Album, 'backside_art', widgets.AdminFileWidget)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
|
||||
fixtures = ["admin-widgets-users.xml"]
|
||||
|
||||
|
@ -135,6 +137,7 @@ class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
|
|||
self.assertContains(response, "Volkswagon Passat")
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminForeignKeyWidgetChangeList(DjangoTestCase):
|
||||
fixtures = ["admin-widgets-users.xml"]
|
||||
admin_root = '/widget_admin'
|
||||
|
@ -150,6 +153,7 @@ class AdminForeignKeyWidgetChangeList(DjangoTestCase):
|
|||
self.assertContains(response, '%s/auth/user/add/' % self.admin_root)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AdminForeignKeyRawIdWidget(DjangoTestCase):
|
||||
fixtures = ["admin-widgets-users.xml"]
|
||||
admin_root = '/widget_admin'
|
||||
|
@ -411,6 +415,7 @@ class RelatedFieldWidgetWrapperTests(DjangoTestCase):
|
|||
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class DateTimePickerSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
|
||||
fixtures = ['admin-widgets-users.xml']
|
||||
|
@ -466,6 +471,7 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
|
|||
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
|
||||
fixtures = ['admin-widgets-users.xml']
|
||||
|
|
|
@ -6,6 +6,7 @@ from django.contrib.comments.models import Comment
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.sites.models import Site
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from ..models import Article, Author
|
||||
|
||||
|
@ -13,6 +14,7 @@ from ..models import Article, Author
|
|||
CT = ContentType.objects.get_for_model
|
||||
|
||||
# Helper base class for comment tests that need data.
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.UnsaltedMD5PasswordHasher',))
|
||||
class CommentTestCase(TestCase):
|
||||
fixtures = ["comment_tests"]
|
||||
urls = 'django.contrib.comments.urls'
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.contrib.auth.models import User, Permission
|
|||
from django.contrib.comments import signals
|
||||
from django.contrib.comments.models import Comment, CommentFlag
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.conf import settings
|
||||
|
||||
from . import CommentTestCase
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ from django.contrib.contenttypes.generic import (
|
|||
generic_inlineformset_factory, GenericTabularInline)
|
||||
from django.forms.models import ModelForm
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
# local test models
|
||||
from .admin import MediaInline, MediaPermanentInline
|
||||
|
@ -16,6 +17,7 @@ from .models import (Episode, EpisodeExtra, EpisodeMaxNum, Media,
|
|||
EpisodePermanent, Category)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class GenericAdminViewTest(TestCase):
|
||||
urls = "regressiontests.generic_inline_admin.urls"
|
||||
fixtures = ['users.xml']
|
||||
|
@ -128,6 +130,7 @@ class GenericAdminViewTest(TestCase):
|
|||
formset = inline_formset(instance=e)
|
||||
self.assertTrue(formset.get_queryset().ordered)
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class GenericInlineAdminParametersTest(TestCase):
|
||||
urls = "regressiontests.generic_inline_admin.urls"
|
||||
fixtures = ['users.xml']
|
||||
|
@ -181,6 +184,7 @@ class GenericInlineAdminParametersTest(TestCase):
|
|||
self.assertEqual(formset.initial_form_count(), 1)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class GenericInlineAdminWithUniqueTogetherTest(TestCase):
|
||||
urls = "regressiontests.generic_inline_admin.urls"
|
||||
fixtures = ['users.xml']
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SpecialHeadersTest(TestCase):
|
||||
fixtures = ['data.xml']
|
||||
urls = 'regressiontests.special_headers.urls'
|
||||
|
|
|
@ -12,7 +12,7 @@ from django.template import (TemplateDoesNotExist, TemplateSyntaxError,
|
|||
import django.template.context
|
||||
from django.test import Client, TestCase
|
||||
from django.test.client import encode_file, RequestFactory
|
||||
from django.test.utils import ContextList
|
||||
from django.test.utils import ContextList, override_settings
|
||||
from django.template.response import SimpleTemplateResponse
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
@ -163,6 +163,7 @@ class AssertContainsTests(TestCase):
|
|||
response = HttpResponse('Hello')
|
||||
self.assertNotContains(response, 'Bye')
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class AssertTemplateUsedTests(TestCase):
|
||||
fixtures = ['testdata.json']
|
||||
|
||||
|
@ -522,6 +523,7 @@ class AssertFormErrorTests(TestCase):
|
|||
except AssertionError as e:
|
||||
self.assertIn("abc: The form 'form' in context 0 does not contain the non-field error 'Some error.' (actual errors: )", str(e))
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class LoginTests(TestCase):
|
||||
fixtures = ['testdata']
|
||||
|
||||
|
@ -542,6 +544,7 @@ class LoginTests(TestCase):
|
|||
self.assertRedirects(response, "http://testserver/test_client_regress/get_view/")
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SessionEngineTests(TestCase):
|
||||
fixtures = ['testdata']
|
||||
|
||||
|
@ -588,6 +591,7 @@ class URLEscapingTests(TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.content, 'Hi, Arthur')
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class ExceptionTests(TestCase):
|
||||
fixtures = ['testdata.json']
|
||||
|
||||
|
@ -661,6 +665,7 @@ class zzUrlconfSubstitutionTests(TestCase):
|
|||
url = reverse('arg_view', args=['somename'])
|
||||
self.assertEqual(url, '/test_client_regress/arg_view/somename/')
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class ContextTests(TestCase):
|
||||
fixtures = ['testdata']
|
||||
|
||||
|
@ -707,6 +712,7 @@ class ContextTests(TestCase):
|
|||
django.template.context._standard_context_processors = None
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class SessionTests(TestCase):
|
||||
fixtures = ['testdata.json']
|
||||
|
||||
|
|
|
@ -22,3 +22,9 @@ DATABASES = {
|
|||
}
|
||||
|
||||
SECRET_KEY = "django_tests_secret_key"
|
||||
# To speed up tests under SQLite we use the MD5 hasher as the default one.
|
||||
# This should not be needed under other databases, as the relative speedup
|
||||
# is only marginal there.
|
||||
PASSWORD_HASHERS = (
|
||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue