Loading django/contrib/auth/tests/models.py +6 −5 Original line number Diff line number Diff line from django.conf import settings from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable, UserManager) from django.test import TestCase from django.test.utils import override_settings from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable, UserManager) from django.utils import six @override_settings(USE_TZ=False, AUTH_PROFILE_MODULE='') Loading @@ -13,19 +14,19 @@ class ProfileTestCase(TestCase): # calling get_profile without AUTH_PROFILE_MODULE set del settings.AUTH_PROFILE_MODULE with self.assertRaisesRegexp(SiteProfileNotAvailable, with six.assertRaisesRegex(self, SiteProfileNotAvailable, "You need to set AUTH_PROFILE_MODULE in your project"): user.get_profile() # Bad syntax in AUTH_PROFILE_MODULE: settings.AUTH_PROFILE_MODULE = 'foobar' with self.assertRaisesRegexp(SiteProfileNotAvailable, with six.assertRaisesRegex(self, SiteProfileNotAvailable, "app_label and model_name should be separated by a dot"): user.get_profile() # module that doesn't exist settings.AUTH_PROFILE_MODULE = 'foo.bar' with self.assertRaisesRegexp(SiteProfileNotAvailable, with six.assertRaisesRegex(self, SiteProfileNotAvailable, "Unable to load the profile model"): user.get_profile() Loading django/contrib/localflavor/hr/forms.py +5 −5 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ HR-specific Form helpers """ from __future__ import absolute_import, unicode_literals import datetime import re from django.contrib.localflavor.hr.hr_choices import ( Loading Loading @@ -91,10 +92,9 @@ class HRJMBGField(Field): dd = int(matches.group('dd')) mm = int(matches.group('mm')) yyy = int(matches.group('yyy')) import datetime try: datetime.date(yyy, mm, dd) except: except ValueError: raise ValidationError(self.error_messages['date']) # Validate checksum. Loading django/contrib/localflavor/ro/forms.py +11 −11 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ Romanian specific form helpers. """ from __future__ import absolute_import, unicode_literals import datetime from django.contrib.localflavor.ro.ro_counties import COUNTIES_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError, Field, RegexField, Select Loading Loading @@ -69,10 +71,9 @@ class ROCNPField(RegexField): if value in EMPTY_VALUES: return '' # check birthdate digits import datetime try: datetime.date(int(value[1:3]), int(value[3:5]), int(value[5:7])) except: except ValueError: raise ValidationError(self.error_messages['invalid']) # checksum key = '279146358279' Loading Loading @@ -202,4 +203,3 @@ class ROPostalCodeField(RegexField): def __init__(self, max_length=6, min_length=6, *args, **kwargs): super(ROPostalCodeField, self).__init__(r'^[0-9][0-8][0-9]{4}$', max_length, min_length, *args, **kwargs) django/core/cache/backends/memcached.py +1 −1 Original line number Diff line number Diff line Loading @@ -141,7 +141,7 @@ class CacheClass(BaseMemcachedCache): ) try: import memcache except: except ImportError: raise InvalidCacheBackendError( "Memcached cache backend requires either the 'memcache' or 'cmemcache' library" ) Loading django/db/backends/creation.py +6 −1 Original line number Diff line number Diff line import hashlib import sys import time from django.conf import settings from django.db.utils import load_backend from django.utils.encoding import force_bytes from django.utils.six.moves import input # The prefix to put on the default database name when creating Loading @@ -29,7 +31,10 @@ class BaseDatabaseCreation(object): Generates a 32-bit digest of a set of arguments that can be used to shorten identifying names. """ return '%x' % (abs(hash(args)) % 4294967296) # 2**32 h = hashlib.md5() for arg in args: h.update(force_bytes(arg)) return h.hexdigest()[:8] def sql_create_model(self, model, style, known_models=set()): """ Loading Loading
django/contrib/auth/tests/models.py +6 −5 Original line number Diff line number Diff line from django.conf import settings from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable, UserManager) from django.test import TestCase from django.test.utils import override_settings from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable, UserManager) from django.utils import six @override_settings(USE_TZ=False, AUTH_PROFILE_MODULE='') Loading @@ -13,19 +14,19 @@ class ProfileTestCase(TestCase): # calling get_profile without AUTH_PROFILE_MODULE set del settings.AUTH_PROFILE_MODULE with self.assertRaisesRegexp(SiteProfileNotAvailable, with six.assertRaisesRegex(self, SiteProfileNotAvailable, "You need to set AUTH_PROFILE_MODULE in your project"): user.get_profile() # Bad syntax in AUTH_PROFILE_MODULE: settings.AUTH_PROFILE_MODULE = 'foobar' with self.assertRaisesRegexp(SiteProfileNotAvailable, with six.assertRaisesRegex(self, SiteProfileNotAvailable, "app_label and model_name should be separated by a dot"): user.get_profile() # module that doesn't exist settings.AUTH_PROFILE_MODULE = 'foo.bar' with self.assertRaisesRegexp(SiteProfileNotAvailable, with six.assertRaisesRegex(self, SiteProfileNotAvailable, "Unable to load the profile model"): user.get_profile() Loading
django/contrib/localflavor/hr/forms.py +5 −5 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ HR-specific Form helpers """ from __future__ import absolute_import, unicode_literals import datetime import re from django.contrib.localflavor.hr.hr_choices import ( Loading Loading @@ -91,10 +92,9 @@ class HRJMBGField(Field): dd = int(matches.group('dd')) mm = int(matches.group('mm')) yyy = int(matches.group('yyy')) import datetime try: datetime.date(yyy, mm, dd) except: except ValueError: raise ValidationError(self.error_messages['date']) # Validate checksum. Loading
django/contrib/localflavor/ro/forms.py +11 −11 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ Romanian specific form helpers. """ from __future__ import absolute_import, unicode_literals import datetime from django.contrib.localflavor.ro.ro_counties import COUNTIES_CHOICES from django.core.validators import EMPTY_VALUES from django.forms import ValidationError, Field, RegexField, Select Loading Loading @@ -69,10 +71,9 @@ class ROCNPField(RegexField): if value in EMPTY_VALUES: return '' # check birthdate digits import datetime try: datetime.date(int(value[1:3]), int(value[3:5]), int(value[5:7])) except: except ValueError: raise ValidationError(self.error_messages['invalid']) # checksum key = '279146358279' Loading Loading @@ -202,4 +203,3 @@ class ROPostalCodeField(RegexField): def __init__(self, max_length=6, min_length=6, *args, **kwargs): super(ROPostalCodeField, self).__init__(r'^[0-9][0-8][0-9]{4}$', max_length, min_length, *args, **kwargs)
django/core/cache/backends/memcached.py +1 −1 Original line number Diff line number Diff line Loading @@ -141,7 +141,7 @@ class CacheClass(BaseMemcachedCache): ) try: import memcache except: except ImportError: raise InvalidCacheBackendError( "Memcached cache backend requires either the 'memcache' or 'cmemcache' library" ) Loading
django/db/backends/creation.py +6 −1 Original line number Diff line number Diff line import hashlib import sys import time from django.conf import settings from django.db.utils import load_backend from django.utils.encoding import force_bytes from django.utils.six.moves import input # The prefix to put on the default database name when creating Loading @@ -29,7 +31,10 @@ class BaseDatabaseCreation(object): Generates a 32-bit digest of a set of arguments that can be used to shorten identifying names. """ return '%x' % (abs(hash(args)) % 4294967296) # 2**32 h = hashlib.md5() for arg in args: h.update(force_bytes(arg)) return h.hexdigest()[:8] def sql_create_model(self, model, style, known_models=set()): """ Loading