diff --git a/django/apps/registry.py b/django/apps/registry.py
index 48694d0f2c..0ac495df1e 100644
--- a/django/apps/registry.py
+++ b/django/apps/registry.py
@@ -422,4 +422,5 @@ class Apps(object):
for function in self._pending_operations.pop(key, []):
function(model)
+
apps = Apps(installed_apps=None)
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index efc9115b65..e9611aa3fe 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -184,4 +184,5 @@ class UserSettingsHolder(BaseSettings):
'cls': self.__class__.__name__,
}
+
settings = LazySettings()
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 9dbbdc9f88..b123c1136b 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -11,6 +11,7 @@ from __future__ import unicode_literals
def gettext_noop(s):
return s
+
####################
# CORE #
####################
diff --git a/django/contrib/admin/actions.py b/django/contrib/admin/actions.py
index 6fdf070694..f07f3549cb 100644
--- a/django/contrib/admin/actions.py
+++ b/django/contrib/admin/actions.py
@@ -86,4 +86,5 @@ def delete_selected(modeladmin, request, queryset):
"admin/delete_selected_confirmation.html"
], context)
+
delete_selected.short_description = ugettext_lazy("Delete selected %(verbose_name_plural)s")
diff --git a/django/contrib/admin/bin/compress.py b/django/contrib/admin/bin/compress.py
index 4d5fbecabc..dbef84d759 100644
--- a/django/contrib/admin/bin/compress.py
+++ b/django/contrib/admin/bin/compress.py
@@ -58,5 +58,6 @@ Compiler library and Java version 6 or later."""
else:
sys.stdout.write("File %s not found. Sure it exists?\n" % to_compress)
+
if __name__ == '__main__':
main()
diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
index 8ff223fb29..87839c3130 100644
--- a/django/contrib/admin/filters.py
+++ b/django/contrib/admin/filters.py
@@ -222,6 +222,7 @@ class RelatedFieldListFilter(FieldListFilter):
'display': self.empty_value_display,
}
+
FieldListFilter.register(lambda f: f.remote_field, RelatedFieldListFilter)
@@ -260,6 +261,7 @@ class BooleanFieldListFilter(FieldListFilter):
'display': _('Unknown'),
}
+
FieldListFilter.register(
lambda f: isinstance(f, (models.BooleanField, models.NullBooleanField)),
BooleanFieldListFilter
@@ -307,6 +309,7 @@ class ChoicesFieldListFilter(FieldListFilter):
'display': none_title,
}
+
FieldListFilter.register(lambda f: bool(f.choices), ChoicesFieldListFilter)
@@ -376,6 +379,7 @@ class DateFieldListFilter(FieldListFilter):
'display': title,
}
+
FieldListFilter.register(
lambda f: isinstance(f, models.DateField), DateFieldListFilter)
@@ -434,6 +438,7 @@ class AllValuesFieldListFilter(FieldListFilter):
'display': self.empty_value_display,
}
+
FieldListFilter.register(lambda f: True, AllValuesFieldListFilter)
diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
index c433f32579..7339d6a0ef 100644
--- a/django/contrib/admin/helpers.py
+++ b/django/contrib/admin/helpers.py
@@ -32,6 +32,7 @@ class ActionForm(forms.Form):
widget=forms.HiddenInput({'class': 'select-across'}),
)
+
checkbox = forms.CheckboxInput({'class': 'action-select'}, lambda value: False)
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 499d27d02e..33daf244f0 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -70,6 +70,7 @@ def get_ul_class(radio_style):
class IncorrectLookupParameters(Exception):
pass
+
# Defaults for formfield_overrides. ModelAdmin subclasses can change this
# by adding to ModelAdmin.formfield_overrides.
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index fc46f030c2..dfe91e23e1 100644
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -501,6 +501,7 @@ class AdminSite(object):
'admin/app_index.html'
], context)
+
# This global object represents the default admin site, for the common case.
# You can instantiate AdminSite in your own code to create a custom admin site.
site = AdminSite()
diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py
index e532079b62..1d6e700fc9 100644
--- a/django/contrib/admindocs/utils.py
+++ b/django/contrib/admindocs/utils.py
@@ -89,6 +89,7 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None):
)
return mark_safe(parts['fragment'])
+
#
# reST roles
#
@@ -137,6 +138,7 @@ def default_reference_role(name, rawtext, text, lineno, inliner, options=None, c
)
return [node], []
+
if docutils_is_available:
docutils.parsers.rst.roles.register_canonical_role('cmsreference', default_reference_role)
diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py
index 476d883a8d..7e894b51fc 100644
--- a/django/contrib/admindocs/views.py
+++ b/django/contrib/admindocs/views.py
@@ -425,6 +425,7 @@ def extract_views_from_urlpatterns(urlpatterns, base='', namespace=None):
raise TypeError(_("%s does not appear to be a urlpattern object") % p)
return views
+
named_group_matcher = re.compile(r'\(\?P(<\w+>).+?\)')
non_named_group_matcher = re.compile(r'\(.*?\)')
diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py
index a490eff040..7adb8a022f 100644
--- a/django/contrib/auth/__init__.py
+++ b/django/contrib/auth/__init__.py
@@ -231,4 +231,5 @@ def update_session_auth_hash(request, user):
if hasattr(user, 'get_session_auth_hash') and request.user == user:
request.session[HASH_SESSION_KEY] = user.get_session_auth_hash()
+
default_app_config = 'django.contrib.auth.apps.AuthConfig'
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index eef38c17ee..8bcf3c867f 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -23,6 +23,8 @@ def update_last_login(sender, user, **kwargs):
"""
user.last_login = timezone.now()
user.save(update_fields=['last_login'])
+
+
user_logged_in.connect(update_last_login)
diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py
index bee6bff942..12cf29cb9b 100644
--- a/django/contrib/auth/password_validation.py
+++ b/django/contrib/auth/password_validation.py
@@ -88,6 +88,8 @@ def _password_validators_help_text_html(password_validators=None):
help_texts = password_validators_help_texts(password_validators)
help_items = [format_html('
{}', help_text) for help_text in help_texts]
return '' % ''.join(help_items) if help_items else ''
+
+
password_validators_help_text_html = lazy(_password_validators_help_text_html, text_type)
diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py
index 45145ab87d..46b8467476 100644
--- a/django/contrib/auth/tokens.py
+++ b/django/contrib/auth/tokens.py
@@ -78,4 +78,5 @@ class PasswordResetTokenGenerator(object):
# Used for mocking in tests
return date.today()
+
default_token_generator = PasswordResetTokenGenerator()
diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py
index 08f5aa81f9..a3813edd58 100644
--- a/django/contrib/gis/db/models/fields.py
+++ b/django/contrib/gis/db/models/fields.py
@@ -249,6 +249,7 @@ class BaseSpatialField(Field):
else:
return obj
+
for klass in gis_lookups.values():
BaseSpatialField.register_lookup(klass)
diff --git a/django/contrib/gis/db/models/lookups.py b/django/contrib/gis/db/models/lookups.py
index ee68f3d5cd..19a1b70e4e 100644
--- a/django/contrib/gis/db/models/lookups.py
+++ b/django/contrib/gis/db/models/lookups.py
@@ -158,6 +158,8 @@ class OverlapsLeftLookup(GISLookup):
left of B's bounding box.
"""
lookup_name = 'overlaps_left'
+
+
gis_lookups['overlaps_left'] = OverlapsLeftLookup
@@ -167,6 +169,8 @@ class OverlapsRightLookup(GISLookup):
right of B's bounding box.
"""
lookup_name = 'overlaps_right'
+
+
gis_lookups['overlaps_right'] = OverlapsRightLookup
@@ -176,6 +180,8 @@ class OverlapsBelowLookup(GISLookup):
B's bounding box.
"""
lookup_name = 'overlaps_below'
+
+
gis_lookups['overlaps_below'] = OverlapsBelowLookup
@@ -185,6 +191,8 @@ class OverlapsAboveLookup(GISLookup):
B's bounding box.
"""
lookup_name = 'overlaps_above'
+
+
gis_lookups['overlaps_above'] = OverlapsAboveLookup
@@ -194,6 +202,8 @@ class LeftLookup(GISLookup):
of B's bounding box.
"""
lookup_name = 'left'
+
+
gis_lookups['left'] = LeftLookup
@@ -203,6 +213,8 @@ class RightLookup(GISLookup):
of B's bounding box.
"""
lookup_name = 'right'
+
+
gis_lookups['right'] = RightLookup
@@ -212,6 +224,8 @@ class StrictlyBelowLookup(GISLookup):
bounding box.
"""
lookup_name = 'strictly_below'
+
+
gis_lookups['strictly_below'] = StrictlyBelowLookup
@@ -221,6 +235,8 @@ class StrictlyAboveLookup(GISLookup):
bounding box.
"""
lookup_name = 'strictly_above'
+
+
gis_lookups['strictly_above'] = StrictlyAboveLookup
@@ -231,12 +247,16 @@ class SameAsLookup(GISLookup):
vertex-by-vertex, the operator returns true.
"""
lookup_name = 'same_as'
+
+
gis_lookups['same_as'] = SameAsLookup
class ExactLookup(SameAsLookup):
# Alias of same_as
lookup_name = 'exact'
+
+
gis_lookups['exact'] = ExactLookup
@@ -246,6 +266,8 @@ class BBContainsLookup(GISLookup):
by B's bounding box.
"""
lookup_name = 'bbcontains'
+
+
gis_lookups['bbcontains'] = BBContainsLookup
@@ -254,6 +276,8 @@ class BBOverlapsLookup(GISLookup):
The 'bboverlaps' operator returns true if A's bounding box overlaps B's bounding box.
"""
lookup_name = 'bboverlaps'
+
+
gis_lookups['bboverlaps'] = BBOverlapsLookup
@@ -263,6 +287,8 @@ class ContainedLookup(GISLookup):
by B's bounding box.
"""
lookup_name = 'contained'
+
+
gis_lookups['contained'] = ContainedLookup
@@ -272,41 +298,57 @@ gis_lookups['contained'] = ContainedLookup
class ContainsLookup(GISLookup):
lookup_name = 'contains'
+
+
gis_lookups['contains'] = ContainsLookup
class ContainsProperlyLookup(GISLookup):
lookup_name = 'contains_properly'
+
+
gis_lookups['contains_properly'] = ContainsProperlyLookup
class CoveredByLookup(GISLookup):
lookup_name = 'coveredby'
+
+
gis_lookups['coveredby'] = CoveredByLookup
class CoversLookup(GISLookup):
lookup_name = 'covers'
+
+
gis_lookups['covers'] = CoversLookup
class CrossesLookup(GISLookup):
lookup_name = 'crosses'
+
+
gis_lookups['crosses'] = CrossesLookup
class DisjointLookup(GISLookup):
lookup_name = 'disjoint'
+
+
gis_lookups['disjoint'] = DisjointLookup
class EqualsLookup(GISLookup):
lookup_name = 'equals'
+
+
gis_lookups['equals'] = EqualsLookup
class IntersectsLookup(GISLookup):
lookup_name = 'intersects'
+
+
gis_lookups['intersects'] = IntersectsLookup
@@ -322,11 +364,15 @@ class IsValidLookup(BuiltinLookup):
if not self.rhs:
sql = 'NOT ' + sql
return sql, params
+
+
gis_lookups['isvalid'] = IsValidLookup
class OverlapsLookup(GISLookup):
lookup_name = 'overlaps'
+
+
gis_lookups['overlaps'] = OverlapsLookup
@@ -347,16 +393,22 @@ class RelateLookup(GISLookup):
if not isinstance(pattern, six.string_types) or not self.pattern_regex.match(pattern):
raise ValueError('Invalid intersection matrix pattern "%s".' % pattern)
return super(RelateLookup, self).get_db_prep_lookup(value, connection)
+
+
gis_lookups['relate'] = RelateLookup
class TouchesLookup(GISLookup):
lookup_name = 'touches'
+
+
gis_lookups['touches'] = TouchesLookup
class WithinLookup(GISLookup):
lookup_name = 'within'
+
+
gis_lookups['within'] = WithinLookup
@@ -395,24 +447,34 @@ class DistanceLookupBase(GISLookup):
class DWithinLookup(DistanceLookupBase):
lookup_name = 'dwithin'
sql_template = '%(func)s(%(lhs)s, %(rhs)s, %%s)'
+
+
gis_lookups['dwithin'] = DWithinLookup
class DistanceGTLookup(DistanceLookupBase):
lookup_name = 'distance_gt'
+
+
gis_lookups['distance_gt'] = DistanceGTLookup
class DistanceGTELookup(DistanceLookupBase):
lookup_name = 'distance_gte'
+
+
gis_lookups['distance_gte'] = DistanceGTELookup
class DistanceLTLookup(DistanceLookupBase):
lookup_name = 'distance_lt'
+
+
gis_lookups['distance_lt'] = DistanceLTLookup
class DistanceLTELookup(DistanceLookupBase):
lookup_name = 'distance_lte'
+
+
gis_lookups['distance_lte'] = DistanceLTELookup
diff --git a/django/contrib/gis/gdal/error.py b/django/contrib/gis/gdal/error.py
index 4dc0b71678..caaf866462 100644
--- a/django/contrib/gis/gdal/error.py
+++ b/django/contrib/gis/gdal/error.py
@@ -27,6 +27,7 @@ class OGRIndexError(GDALException, KeyError):
"""
silent_variable_failure = True
+
# #### GDAL/OGR error checking codes and routine ####
# OGR Error Codes
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index 4407e147e5..cab40aa751 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -692,6 +692,7 @@ class MultiLineString(GeometryCollection):
class MultiPolygon(GeometryCollection):
pass
+
# Class mapping dictionary (using the OGRwkbGeometryType as the key)
GEO_CLASSES = {1: Point,
2: LineString,
diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py
index 020234520e..7d7292b7b8 100644
--- a/django/contrib/gis/gdal/libgdal.py
+++ b/django/contrib/gis/gdal/libgdal.py
@@ -66,6 +66,7 @@ def std_call(func):
else:
return lgdal[func]
+
# #### Version-information functions. ####
# Returns GDAL library version information with the given key.
@@ -83,6 +84,7 @@ def gdal_full_version():
"Returns the full GDAL version information."
return _version_info('')
+
version_regex = re.compile(r'^(?P\d+)\.(?P\d+)(\.(?P\d+))?')
@@ -93,6 +95,7 @@ def gdal_version_info():
raise GDALException('Could not parse GDAL version string "%s"' % ver)
return {key: m.group(key) for key in ('major', 'minor', 'subminor')}
+
_verinfo = gdal_version_info()
GDAL_MAJOR_VERSION = int(_verinfo['major'])
GDAL_MINOR_VERSION = int(_verinfo['minor'])
@@ -106,6 +109,8 @@ CPLErrorHandler = CFUNCTYPE(None, c_int, c_int, c_char_p)
def err_handler(error_class, error_number, message):
logger.error('GDAL_ERROR %d: %s', error_number, message)
+
+
err_handler = CPLErrorHandler(err_handler)
@@ -115,5 +120,6 @@ def function(name, args, restype):
func.restype = restype
return func
+
set_error_handler = function('CPLSetErrorHandler', [CPLErrorHandler], CPLErrorHandler)
set_error_handler(err_handler)
diff --git a/django/contrib/gis/gdal/prototypes/geom.py b/django/contrib/gis/gdal/prototypes/geom.py
index aac8b99bae..a66b18842d 100644
--- a/django/contrib/gis/gdal/prototypes/geom.py
+++ b/django/contrib/gis/gdal/prototypes/geom.py
@@ -29,6 +29,7 @@ def topology_func(f):
f.errcheck = lambda result, func, cargs: bool(result)
return f
+
# ### OGR_G ctypes function prototypes ###
# GeoJSON routines.
diff --git a/django/contrib/gis/gdal/prototypes/srs.py b/django/contrib/gis/gdal/prototypes/srs.py
index 1ea8a77701..f53a601a59 100644
--- a/django/contrib/gis/gdal/prototypes/srs.py
+++ b/django/contrib/gis/gdal/prototypes/srs.py
@@ -23,6 +23,7 @@ def units_func(f):
"""
return double_output(f, [c_void_p, POINTER(c_char_p)], strarg=True)
+
# Creation & destruction.
clone_srs = srs_output(std_call('OSRClone'), [c_void_p])
new_srs = srs_output(std_call('OSRNewSpatialReference'), [c_char_p])
diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py
index 257e0ffacd..74b9b2142f 100644
--- a/django/contrib/gis/geoip/prototypes.py
+++ b/django/contrib/gis/geoip/prototypes.py
@@ -23,6 +23,8 @@ class GeoIPRecord(Structure):
('charset', c_int),
('continent_code', c_char_p),
]
+
+
geoip_char_fields = [name for name, ctype in GeoIPRecord._fields_ if ctype is c_char_p]
GEOIP_DEFAULT_ENCODING = 'iso-8859-1'
geoip_encodings = {
@@ -34,6 +36,7 @@ geoip_encodings = {
class GeoIPTag(Structure):
pass
+
RECTYPE = POINTER(GeoIPRecord)
DBTYPE = POINTER(GeoIPTag)
@@ -79,6 +82,8 @@ def record_output(func):
func.restype = RECTYPE
func.errcheck = check_record
return func
+
+
GeoIP_record_by_addr = record_output(lgeoip.GeoIP_record_by_addr)
GeoIP_record_by_name = record_output(lgeoip.GeoIP_record_by_name)
@@ -104,6 +109,7 @@ def check_string(result, func, cargs):
s = ''
return s.decode(GEOIP_DEFAULT_ENCODING)
+
GeoIP_database_info = lgeoip.GeoIP_database_info
GeoIP_database_info.restype = geoip_char_p
GeoIP_database_info.errcheck = check_string
@@ -119,6 +125,7 @@ def string_output(func):
func.errcheck = _err_check
return func
+
GeoIP_country_code_by_addr = string_output(lgeoip.GeoIP_country_code_by_addr)
GeoIP_country_code_by_name = string_output(lgeoip.GeoIP_country_code_by_name)
GeoIP_country_name_by_addr = string_output(lgeoip.GeoIP_country_name_by_addr)
diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py
index 01277b1b65..7427a4569f 100644
--- a/django/contrib/gis/geos/collections.py
+++ b/django/contrib/gis/geos/collections.py
@@ -137,6 +137,7 @@ class MultiPolygon(GeometryCollection):
)
return GEOSGeometry(capi.geos_cascaded_union(self.ptr), self.srid)
+
# Setting the allowed types here since GeometryCollection is defined before
# its subclasses.
GeometryCollection._allowed = (Point, LineString, LinearRing, Polygon, MultiPoint, MultiLineString, MultiPolygon)
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index df7e2aa5d5..48532d5c53 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -83,6 +83,8 @@ def notice_h(fmt, lst):
except TypeError:
warn_msg = fmt
logger.warning('GEOS_NOTICE: %s\n', warn_msg)
+
+
notice_h = NOTICEFUNC(notice_h)
ERRORFUNC = CFUNCTYPE(None, c_char_p, c_char_p)
@@ -95,6 +97,8 @@ def error_h(fmt, lst):
except TypeError:
err_msg = fmt
logger.error('GEOS_ERROR: %s\n', err_msg)
+
+
error_h = ERRORFUNC(error_h)
# #### GEOS Geometry C data structures, and utility functions. ####
@@ -116,6 +120,7 @@ class GEOSCoordSeq_t(Structure):
class GEOSContextHandle_t(Structure):
pass
+
# Pointers to opaque GEOS geometry structures.
GEOM_PTR = POINTER(GEOSGeom_t)
PREPGEOM_PTR = POINTER(GEOSPrepGeom_t)
diff --git a/django/contrib/gis/geos/prototypes/io.py b/django/contrib/gis/geos/prototypes/io.py
index 161541d6f4..8ac4cfa21e 100644
--- a/django/contrib/gis/geos/prototypes/io.py
+++ b/django/contrib/gis/geos/prototypes/io.py
@@ -27,6 +27,7 @@ class WKBReader_st(Structure):
class WKBWriter_st(Structure):
pass
+
WKT_READ_PTR = POINTER(WKTReader_st)
WKT_WRITE_PTR = POINTER(WKTWriter_st)
WKB_READ_PTR = POINTER(WKBReader_st)
@@ -101,6 +102,7 @@ class WKBWriterGet(GEOSFuncFactory):
class WKBWriterSet(GEOSFuncFactory):
argtypes = [WKB_WRITE_PTR, c_int]
+
wkb_writer_get_byteorder = WKBWriterGet('GEOSWKBWriter_getByteOrder')
wkb_writer_set_byteorder = WKBWriterSet('GEOSWKBWriter_setByteOrder')
wkb_writer_get_outdim = WKBWriterGet('GEOSWKBWriter_getOutputDimension')
@@ -281,6 +283,7 @@ class ThreadLocalIO(threading.local):
wkb_w = None
ewkb_w = None
+
thread_context = ThreadLocalIO()
diff --git a/django/contrib/gis/geos/prototypes/threadsafe.py b/django/contrib/gis/geos/prototypes/threadsafe.py
index 45c87d6004..8345c385df 100644
--- a/django/contrib/gis/geos/prototypes/threadsafe.py
+++ b/django/contrib/gis/geos/prototypes/threadsafe.py
@@ -24,6 +24,7 @@ class GEOSContextHandle(object):
class GEOSContext(threading.local):
handle = None
+
thread_context = GEOSContext()
diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
index 6c43ace840..d7d8f2f897 100644
--- a/django/contrib/humanize/templatetags/humanize.py
+++ b/django/contrib/humanize/templatetags/humanize.py
@@ -55,6 +55,7 @@ def intcomma(value, use_l10n=True):
else:
return intcomma(new, use_l10n)
+
# A tuple of standard large number to their converters
intword_converters = (
(6, lambda number: (
diff --git a/django/contrib/postgres/fields/hstore.py b/django/contrib/postgres/fields/hstore.py
index 8322d8170c..76f41886a9 100644
--- a/django/contrib/postgres/fields/hstore.py
+++ b/django/contrib/postgres/fields/hstore.py
@@ -69,6 +69,7 @@ class HStoreField(Field):
return value
+
HStoreField.register_lookup(lookups.DataContains)
HStoreField.register_lookup(lookups.ContainedBy)
HStoreField.register_lookup(lookups.HasKey)
diff --git a/django/contrib/sites/models.py b/django/contrib/sites/models.py
index 744ccd358c..e4c68638da 100644
--- a/django/contrib/sites/models.py
+++ b/django/contrib/sites/models.py
@@ -121,5 +121,7 @@ def clear_site_cache(sender, **kwargs):
del SITE_CACHE[Site.objects.using(using).get(pk=instance.pk).domain]
except (KeyError, Site.DoesNotExist):
pass
+
+
pre_save.connect(clear_site_cache, sender=Site)
pre_delete.connect(clear_site_cache, sender=Site)
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index d59a9cc122..a1d787548a 100644
--- a/django/contrib/staticfiles/storage.py
+++ b/django/contrib/staticfiles/storage.py
@@ -405,4 +405,5 @@ class ConfiguredStorage(LazyObject):
def _setup(self):
self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
+
staticfiles_storage = ConfiguredStorage()
diff --git a/django/contrib/staticfiles/urls.py b/django/contrib/staticfiles/urls.py
index 5f27f4f14d..6278f35b35 100644
--- a/django/contrib/staticfiles/urls.py
+++ b/django/contrib/staticfiles/urls.py
@@ -13,6 +13,7 @@ def staticfiles_urlpatterns(prefix=None):
prefix = settings.STATIC_URL
return static(prefix, view=serve)
+
# Only append if urlpatterns are empty
if settings.DEBUG and not urlpatterns:
urlpatterns += staticfiles_urlpatterns()
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py
index 26897ff850..cd2bb43886 100644
--- a/django/core/cache/__init__.py
+++ b/django/core/cache/__init__.py
@@ -84,6 +84,7 @@ class CacheHandler(object):
def all(self):
return getattr(self._caches, 'caches', {}).values()
+
caches = CacheHandler()
@@ -112,6 +113,7 @@ class DefaultCacheProxy(object):
def __ne__(self, other):
return caches[DEFAULT_CACHE_ALIAS] != other
+
cache = DefaultCacheProxy()
@@ -121,4 +123,6 @@ def close_caches(**kwargs):
# cache.close is a no-op
for cache in caches.all():
cache.close()
+
+
signals.request_finished.connect(close_caches)
diff --git a/django/core/checks/security/sessions.py b/django/core/checks/security/sessions.py
index 5fae4ed4d9..bb361e7b50 100644
--- a/django/core/checks/security/sessions.py
+++ b/django/core/checks/security/sessions.py
@@ -10,6 +10,7 @@ def add_session_cookie_message(message):
"network traffic sniffers to hijack user sessions."
)
+
W010 = Warning(
add_session_cookie_message(
"You have 'django.contrib.sessions' in your INSTALLED_APPS, "
diff --git a/django/core/files/storage.py b/django/core/files/storage.py
index e219bbcf19..98c89ddcfa 100644
--- a/django/core/files/storage.py
+++ b/django/core/files/storage.py
@@ -471,4 +471,5 @@ class DefaultStorage(LazyObject):
def _setup(self):
self._wrapped = get_storage_class()()
+
default_storage = DefaultStorage()
diff --git a/django/core/mail/utils.py b/django/core/mail/utils.py
index 322a3a1b79..9295759fad 100644
--- a/django/core/mail/utils.py
+++ b/django/core/mail/utils.py
@@ -16,4 +16,5 @@ class CachedDnsName(object):
self._fqdn = socket.getfqdn()
return self._fqdn
+
DNS_NAME = CachedDnsName()
diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
index 18c2d61a88..b757783e5e 100644
--- a/django/core/management/commands/runserver.py
+++ b/django/core/management/commands/runserver.py
@@ -161,5 +161,6 @@ class Command(BaseCommand):
self.stdout.write(shutdown_message)
sys.exit(0)
+
# Kept for backward compatibility
BaseRunserverCommand = Command
diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py
index 04adc8129a..5dc847d4f5 100644
--- a/django/core/serializers/pyyaml.py
+++ b/django/core/serializers/pyyaml.py
@@ -33,6 +33,7 @@ class DjangoSafeDumper(SafeDumper):
def represent_ordered_dict(self, data):
return self.represent_mapping('tag:yaml.org,2002:map', data.items())
+
DjangoSafeDumper.add_representer(decimal.Decimal, DjangoSafeDumper.represent_decimal)
DjangoSafeDumper.add_representer(collections.OrderedDict, DjangoSafeDumper.represent_ordered_dict)
diff --git a/django/core/validators.py b/django/core/validators.py
index 067a3743eb..3f777254f4 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -155,6 +155,7 @@ class URLValidator(RegexValidator):
if len(urlsplit(value).netloc) > 253:
raise ValidationError(self.message, code=self.code)
+
integer_validator = RegexValidator(
_lazy_re_compile(r'^-?\d+\Z'),
message=_('Enter a valid integer.'),
@@ -236,6 +237,7 @@ class EmailValidator(object):
(self.code == other.code)
)
+
validate_email = EmailValidator()
slug_re = _lazy_re_compile(r'^[-a-zA-Z0-9_]+\Z')
@@ -270,6 +272,7 @@ def validate_ipv46_address(value):
except ValidationError:
raise ValidationError(_('Enter a valid IPv4 or IPv6 address.'), code='invalid')
+
ip_address_validator_map = {
'both': ([validate_ipv46_address], _('Enter a valid IPv4 or IPv6 address.')),
'ipv4': ([validate_ipv4_address], _('Enter a valid IPv4 address.')),
@@ -500,6 +503,7 @@ def get_available_image_extensions():
Image.init()
return [ext.lower()[1:] for ext in Image.EXTENSION.keys()]
+
validate_image_file_extension = FileExtensionValidator(
allowed_extensions=get_available_image_extensions(),
)
diff --git a/django/db/__init__.py b/django/db/__init__.py
index f1e21930f9..d25a9f0116 100644
--- a/django/db/__init__.py
+++ b/django/db/__init__.py
@@ -44,6 +44,7 @@ class DefaultConnectionProxy(object):
def __ne__(self, other):
return connections[DEFAULT_DB_ALIAS] != other
+
connection = DefaultConnectionProxy()
@@ -51,6 +52,8 @@ connection = DefaultConnectionProxy()
def reset_queries(**kwargs):
for conn in connections.all():
conn.queries_log.clear()
+
+
signals.request_started.connect(reset_queries)
@@ -59,5 +62,7 @@ signals.request_started.connect(reset_queries)
def close_old_connections(**kwargs):
for conn in connections.all():
conn.close_if_unusable_or_obsolete()
+
+
signals.request_started.connect(close_old_connections)
signals.request_finished.connect(close_old_connections)
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 507b15e531..9681bb4f33 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -65,6 +65,7 @@ def adapt_datetime_warn_on_aware_datetime(value, conv):
value = value.astimezone(timezone.utc).replace(tzinfo=None)
return Thing2Literal(value.strftime("%Y-%m-%d %H:%M:%S.%f"), conv)
+
# MySQLdb-1.2.1 returns TIME columns as timedelta -- they are more like
# timedelta in terms of actual behavior as they are signed and include days --
# and Django expects time, so we still need to override that. We also need to
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index b5182469b7..2e6f02cc14 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -39,6 +39,7 @@ def _setup_environment(environ):
else:
os.environ.update(environ)
+
_setup_environment([
# Oracle takes client-side character set encoding from the environment.
('NLS_LANG', '.AL32UTF8'),
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index d188f37853..b4008532ee 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -28,6 +28,7 @@ def psycopg2_version():
version = psycopg2.__version__.split(' ', 1)[0]
return tuple(int(v) for v in version.split('.') if v.isdigit())
+
PSYCOPG2_VERSION = psycopg2_version()
if PSYCOPG2_VERSION < (2, 4, 5):
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index aee012c7e6..ac7799bfa5 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -64,6 +64,7 @@ def decoder(conv_func):
"""
return lambda s: conv_func(s.decode('utf-8'))
+
Database.register_converter(str("bool"), decoder(lambda s: s == '1'))
Database.register_converter(str("time"), decoder(parse_time))
Database.register_converter(str("date"), decoder(parse_date))
diff --git a/django/db/models/base.py b/django/db/models/base.py
index e7b3f3fd71..42b0a75728 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -48,6 +48,7 @@ class Deferred(object):
def __str__(self):
return str('')
+
DEFERRED = Deferred()
@@ -1772,6 +1773,8 @@ def model_unpickle(model_id):
# Backwards compat - the model was cached directly in earlier versions.
model = model_id
return model.__new__(model)
+
+
model_unpickle.__safe_for_unpickle__ = True
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 1ab2b6d313..40f1411c58 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -61,6 +61,7 @@ class Empty(object):
class NOT_PROVIDED:
pass
+
# The values to use for "blank" in SelectFields. Will be appended to the start
# of most "choices" lists.
BLANK_CHOICE_DASH = [("", "---------")]
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 50b98f1d4f..a872e6ffbd 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -756,6 +756,7 @@ class ForeignObject(RelatedField):
if self.remote_field.limit_choices_to:
cls._meta.related_fkey_lookups.append(self.remote_field.limit_choices_to)
+
ForeignObject.register_lookup(RelatedIn)
ForeignObject.register_lookup(RelatedExact)
ForeignObject.register_lookup(RelatedLessThan)
diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py
index 49b225d880..78cea19037 100644
--- a/django/db/models/lookups.py
+++ b/django/db/models/lookups.py
@@ -234,6 +234,8 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup):
lookup_name = 'exact'
+
+
Field.register_lookup(Exact)
@@ -253,21 +255,29 @@ Field.register_lookup(IExact)
class GreaterThan(FieldGetDbPrepValueMixin, BuiltinLookup):
lookup_name = 'gt'
+
+
Field.register_lookup(GreaterThan)
class GreaterThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup):
lookup_name = 'gte'
+
+
Field.register_lookup(GreaterThanOrEqual)
class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup):
lookup_name = 'lt'
+
+
Field.register_lookup(LessThan)
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup):
lookup_name = 'lte'
+
+
Field.register_lookup(LessThanOrEqual)
@@ -284,11 +294,15 @@ class IntegerFieldFloatRounding(object):
class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual):
pass
+
+
IntegerField.register_lookup(IntegerGreaterThanOrEqual)
class IntegerLessThan(IntegerFieldFloatRounding, LessThan):
pass
+
+
IntegerField.register_lookup(IntegerLessThan)
@@ -350,6 +364,8 @@ class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
params.extend(sqls_params)
in_clause_elements.append(')')
return ''.join(in_clause_elements), params
+
+
Field.register_lookup(In)
@@ -381,12 +397,16 @@ class Contains(PatternLookup):
if params and not self.bilateral_transforms:
params[0] = "%%%s%%" % connection.ops.prep_for_like_query(params[0])
return rhs, params
+
+
Field.register_lookup(Contains)
class IContains(Contains):
lookup_name = 'icontains'
prepare_rhs = False
+
+
Field.register_lookup(IContains)
@@ -399,6 +419,8 @@ class StartsWith(PatternLookup):
if params and not self.bilateral_transforms:
params[0] = "%s%%" % connection.ops.prep_for_like_query(params[0])
return rhs, params
+
+
Field.register_lookup(StartsWith)
@@ -411,6 +433,8 @@ class IStartsWith(PatternLookup):
if params and not self.bilateral_transforms:
params[0] = "%s%%" % connection.ops.prep_for_like_query(params[0])
return rhs, params
+
+
Field.register_lookup(IStartsWith)
@@ -423,6 +447,8 @@ class EndsWith(PatternLookup):
if params and not self.bilateral_transforms:
params[0] = "%%%s" % connection.ops.prep_for_like_query(params[0])
return rhs, params
+
+
Field.register_lookup(EndsWith)
@@ -435,6 +461,8 @@ class IEndsWith(PatternLookup):
if params and not self.bilateral_transforms:
params[0] = "%%%s" % connection.ops.prep_for_like_query(params[0])
return rhs, params
+
+
Field.register_lookup(IEndsWith)
@@ -444,6 +472,7 @@ class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
def get_rhs_op(self, connection, rhs):
return "BETWEEN %s AND %s" % (rhs[0], rhs[1])
+
Field.register_lookup(Range)
@@ -457,6 +486,8 @@ class IsNull(BuiltinLookup):
return "%s IS NULL" % sql, params
else:
return "%s IS NOT NULL" % sql, params
+
+
Field.register_lookup(IsNull)
@@ -473,6 +504,8 @@ class Search(BuiltinLookup):
rhs, rhs_params = self.process_rhs(compiler, connection)
sql_template = connection.ops.fulltext_search_sql(field_name=lhs)
return sql_template, lhs_params + rhs_params
+
+
Field.register_lookup(Search)
@@ -488,11 +521,15 @@ class Regex(BuiltinLookup):
rhs, rhs_params = self.process_rhs(compiler, connection)
sql_template = connection.ops.regex_lookup(self.lookup_name)
return sql_template % (lhs, rhs), lhs_params + rhs_params
+
+
Field.register_lookup(Regex)
class IRegex(Regex):
lookup_name = 'iregex'
+
+
Field.register_lookup(IRegex)
diff --git a/django/dispatch/dispatcher.py b/django/dispatch/dispatcher.py
index 30f339a47c..8b26c39055 100644
--- a/django/dispatch/dispatcher.py
+++ b/django/dispatch/dispatcher.py
@@ -18,6 +18,8 @@ def _make_id(target):
if hasattr(target, '__func__'):
return (id(target.__self__), id(target.__func__))
return id(target)
+
+
NONE_ID = _make_id(None)
# A marker for caching
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
index 97961f89aa..87d80bdde5 100644
--- a/django/http/multipartparser.py
+++ b/django/http/multipartparser.py
@@ -37,6 +37,7 @@ class InputStreamExhausted(Exception):
"""
pass
+
RAW = "raw"
FILE = "file"
FIELD = "field"
diff --git a/django/template/base.py b/django/template/base.py
index 13037c31aa..32ca251f77 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -1048,6 +1048,7 @@ class VariableNode(Node):
return ''
return render_value_in_context(output, context)
+
# Regex for token keyword arguments
kwarg_re = re.compile(r"(?:(\w+)=)?(.+)")
diff --git a/django/template/smartif.py b/django/template/smartif.py
index b5ae510b0f..ee062d537d 100644
--- a/django/template/smartif.py
+++ b/django/template/smartif.py
@@ -143,6 +143,7 @@ class EndToken(TokenBase):
def nud(self, parser):
raise parser.error_class("Unexpected end of expression in if tag.")
+
EndToken = EndToken()
diff --git a/django/urls/base.py b/django/urls/base.py
index 5185324799..ddf3b64dab 100644
--- a/django/urls/base.py
+++ b/django/urls/base.py
@@ -90,6 +90,7 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
+
reverse_lazy = lazy(reverse, six.text_type)
diff --git a/django/utils/archive.py b/django/utils/archive.py
index 7b163edb1b..13f8afa32f 100644
--- a/django/utils/archive.py
+++ b/django/utils/archive.py
@@ -202,6 +202,7 @@ class ZipArchive(BaseArchive):
def close(self):
self._archive.close()
+
extension_map = {
'.tar': TarArchive,
'.tar.bz2': TarArchive,
diff --git a/django/utils/baseconv.py b/django/utils/baseconv.py
index f550c245d0..f6c82a898a 100644
--- a/django/utils/baseconv.py
+++ b/django/utils/baseconv.py
@@ -92,6 +92,7 @@ class BaseConverter(object):
x = int(x // len(to_digits))
return neg, res
+
base2 = BaseConverter(BASE2_ALPHABET)
base16 = BaseConverter(BASE16_ALPHABET)
base36 = BaseConverter(BASE36_ALPHABET)
diff --git a/django/utils/datetime_safe.py b/django/utils/datetime_safe.py
index d2e5b95241..3cc375b4f6 100644
--- a/django/utils/datetime_safe.py
+++ b/django/utils/datetime_safe.py
@@ -51,6 +51,7 @@ def new_datetime(d):
kw.extend([d.hour, d.minute, d.second, d.microsecond, d.tzinfo])
return datetime(*kw)
+
# This library does not support strftime's "%s" or "%y" format strings.
# Allowed if there's an even number of "%"s because they are escaped.
_illegal_formatting = re.compile(r"((^|[^%])(%%)*%[sy])")
diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py
index ce3c90aa77..2963e60214 100644
--- a/django/utils/deprecation.py
+++ b/django/utils/deprecation.py
@@ -122,6 +122,7 @@ class CallableBool:
def __hash__(self):
return hash(self.value)
+
CallableFalse = CallableBool(False)
CallableTrue = CallableBool(True)
diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index 66077e2108..999ffae19a 100644
--- a/django/utils/encoding.py
+++ b/django/utils/encoding.py
@@ -145,6 +145,7 @@ def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
else:
return s.encode(encoding, errors)
+
if six.PY3:
smart_str = smart_text
force_str = force_text
@@ -278,4 +279,5 @@ def get_system_encoding():
encoding = 'ascii'
return encoding
+
DEFAULT_LOCALE_ENCODING = get_system_encoding()
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index aeb054f4e9..c9c1e787f8 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -454,6 +454,7 @@ class Atom1Feed(SyndicationFeed):
)
return self.content_type
+
# This isolates the decision of what the system default is, so calling code can
# do "feedgenerator.DefaultFeed" instead of "feedgenerator.Rss201rev2Feed".
DefaultFeed = Rss201rev2Feed
diff --git a/django/utils/formats.py b/django/utils/formats.py
index 1c59fdd05e..c3d4e29222 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -139,6 +139,7 @@ def get_format(format_type, lang=None, use_l10n=None):
# Return the general setting by default
return getattr(settings, format_type)
+
get_format_lazy = lazy(get_format, six.text_type, list, tuple)
diff --git a/django/utils/functional.py b/django/utils/functional.py
index ee301879df..c317293bb2 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -228,6 +228,7 @@ def keep_lazy_text(func):
"""
return keep_lazy(six.text_type)(func)
+
empty = object()
diff --git a/django/utils/html.py b/django/utils/html.py
index b083df99cf..ff9adffc75 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -50,6 +50,7 @@ def escape(text):
.replace('>', '>').replace('"', '"').replace("'", ''')
)
+
_js_escapes = {
ord('\\'): '\\u005C',
ord('\''): '\\u0027',
diff --git a/django/utils/safestring.py b/django/utils/safestring.py
index cceb9fc3e5..76136d0b0c 100644
--- a/django/utils/safestring.py
+++ b/django/utils/safestring.py
@@ -28,6 +28,7 @@ class EscapeText(six.text_type, EscapeData):
"""
pass
+
if six.PY3:
EscapeString = EscapeText
else:
@@ -109,6 +110,7 @@ class SafeText(six.text_type, SafeData):
encode = curry(_proxy_method, method=six.text_type.encode)
+
if six.PY3:
SafeString = SafeText
else:
diff --git a/django/utils/termcolors.py b/django/utils/termcolors.py
index c7b63336b4..87ed8c1187 100644
--- a/django/utils/termcolors.py
+++ b/django/utils/termcolors.py
@@ -69,6 +69,7 @@ def make_style(opts=(), **kwargs):
"""
return lambda text: colorize(text, opts, **kwargs)
+
NOCOLOR_PALETTE = 'nocolor'
DARK_PALETTE = 'dark'
LIGHT_PALETTE = 'light'
diff --git a/django/utils/text.py b/django/utils/text.py
index 4f8ef9b31b..b0f139e034 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -385,6 +385,7 @@ def _replace_entity(match):
except (ValueError, KeyError):
return match.group(0)
+
_entity_re = re.compile(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));")
@@ -445,4 +446,6 @@ def _format_lazy(format_string, *args, **kwargs):
and/or kwargs might be lazy.
"""
return format_string.format(*args, **kwargs)
+
+
format_lazy = lazy(_format_lazy, six.text_type)
diff --git a/django/utils/timezone.py b/django/utils/timezone.py
index 29885caac8..090750793a 100644
--- a/django/utils/timezone.py
+++ b/django/utils/timezone.py
@@ -50,6 +50,7 @@ class FixedOffset(tzinfo):
def dst(self, dt):
return ZERO
+
utc = pytz.utc
"""UTC time zone as a tzinfo instance."""
@@ -85,6 +86,7 @@ def get_default_timezone_name():
"""
return _get_timezone_name(get_default_timezone())
+
_active = local()
diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
index 39d0f4162b..6cdcaf9bf1 100644
--- a/django/utils/translation/__init__.py
+++ b/django/utils/translation/__init__.py
@@ -63,6 +63,7 @@ class Trans(object):
setattr(self, real_name, getattr(trans, real_name))
return getattr(trans, real_name)
+
_trans = Trans()
# The Trans class is no more needed, so remove it from the namespace.
@@ -72,6 +73,7 @@ del Trans
def gettext_noop(message):
return _trans.gettext_noop(message)
+
ugettext_noop = gettext_noop
@@ -98,6 +100,7 @@ def pgettext(context, message):
def npgettext(context, singular, plural, number):
return _trans.npgettext(context, singular, plural, number)
+
gettext_lazy = lazy(gettext, str)
ugettext_lazy = lazy(ugettext, six.text_type)
pgettext_lazy = lazy(pgettext, six.text_type)
@@ -231,6 +234,8 @@ def _string_concat(*strings):
'favor of django.utils.text.format_lazy().',
RemovedInDjango21Warning, stacklevel=2)
return ''.join(force_text(s) for s in strings)
+
+
string_concat = lazy(_string_concat, six.text_type)
@@ -255,6 +260,7 @@ def get_language_info(lang_code):
info['name_translated'] = ugettext_lazy(info['name'])
return info
+
trim_whitespace_re = re.compile(r'\s*\n\s*')
diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py
index 7d02fa5607..21097244d3 100644
--- a/django/utils/translation/trans_null.py
+++ b/django/utils/translation/trans_null.py
@@ -10,6 +10,8 @@ def ngettext(singular, plural, number):
if number == 1:
return singular
return plural
+
+
ngettext_lazy = ngettext
@@ -55,6 +57,7 @@ def gettext(message):
def ugettext(message):
return force_text(gettext(message))
+
gettext_noop = gettext_lazy = _ = gettext
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 9d246324f0..b3da22482a 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -337,6 +337,7 @@ def gettext(message):
"""
return do_translate(message, 'gettext')
+
if six.PY3:
ugettext = gettext
else:
@@ -384,6 +385,7 @@ def ngettext(singular, plural, number):
"""
return do_ntranslate(singular, plural, number, 'ngettext')
+
if six.PY3:
ungettext = ngettext
else:
diff --git a/django/views/debug.py b/django/views/debug.py
index 1a72ec0405..fff67249c6 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -525,6 +525,7 @@ def default_urlconf(request):
return HttpResponse(t.render(c), content_type='text/html')
+
#
# Templates are embedded in the file so that we know the error handler will
# always work even if the template loader is broken.
diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
index 846d3921cf..21b56a3202 100644
--- a/django/views/decorators/http.py
+++ b/django/views/decorators/http.py
@@ -41,6 +41,7 @@ def require_http_methods(request_method_list):
return inner
return decorator
+
require_GET = require_http_methods(["GET"])
require_GET.__doc__ = "Decorator to require that a view only accepts the GET method."
diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py
index a630c26140..39494e99d3 100644
--- a/tests/admin_changelist/admin.py
+++ b/tests/admin_changelist/admin.py
@@ -24,6 +24,7 @@ class EventAdmin(admin.ModelAdmin):
def has_add_permission(self, request):
return False
+
site.register(Event, EventAdmin)
@@ -98,12 +99,14 @@ class DynamicListDisplayLinksChildAdmin(admin.ModelAdmin):
def get_list_display_links(self, request, list_display):
return ['age']
+
site.register(Child, DynamicListDisplayChildAdmin)
class NoListDisplayLinksParentAdmin(admin.ModelAdmin):
list_display_links = None
+
site.register(Parent, NoListDisplayLinksParentAdmin)
@@ -113,6 +116,7 @@ class SwallowAdmin(admin.ModelAdmin):
list_editable = ['load', 'speed']
list_per_page = 3
+
site.register(Swallow, SwallowAdmin)
diff --git a/tests/admin_ordering/tests.py b/tests/admin_ordering/tests.py
index 44d7beb368..def9b8b7c7 100644
--- a/tests/admin_ordering/tests.py
+++ b/tests/admin_ordering/tests.py
@@ -22,6 +22,7 @@ class MockSuperUser(object):
def has_module_perms(self, module):
return True
+
request = MockRequest()
request.user = MockSuperUser()
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
index 2aa042c386..cdb32a2825 100644
--- a/tests/admin_views/admin.py
+++ b/tests/admin_views/admin.py
@@ -54,6 +54,8 @@ def callable_year(dt_value):
return dt_value.year
except AttributeError:
return None
+
+
callable_year.admin_order_field = 'date'
@@ -252,24 +254,32 @@ def external_mail(modeladmin, request, selected):
'from@example.com',
['to@example.com']
).send()
+
+
external_mail.short_description = 'External mail (Another awesome action)'
def redirect_to(modeladmin, request, selected):
from django.http import HttpResponseRedirect
return HttpResponseRedirect('/some-where-else/')
+
+
redirect_to.short_description = 'Redirect to (Awesome action)'
def download(modeladmin, request, selected):
buf = StringIO('This is the content of the file')
return StreamingHttpResponse(FileWrapper(buf))
+
+
download.short_description = 'Download subscription'
def no_perm(modeladmin, request, selected):
return HttpResponse(content='No permission to perform this action',
status=403)
+
+
no_perm.short_description = 'No permission to run'
@@ -631,6 +641,8 @@ class AdminOrderedAdminMethodAdmin(admin.ModelAdmin):
def admin_ordered_callable(obj):
return obj.order
+
+
admin_ordered_callable.admin_order_field = 'order'
diff --git a/tests/admin_views/test_multidb.py b/tests/admin_views/test_multidb.py
index f5f4d6dc84..102cf35a5d 100644
--- a/tests/admin_views/test_multidb.py
+++ b/tests/admin_views/test_multidb.py
@@ -16,6 +16,7 @@ class Router(object):
db_for_write = db_for_read
+
site = admin.AdminSite(name='test_adminsite')
site.register(Book)
diff --git a/tests/admin_widgets/widgetadmin.py b/tests/admin_widgets/widgetadmin.py
index 6b205b70dc..3dd9997598 100644
--- a/tests/admin_widgets/widgetadmin.py
+++ b/tests/admin_widgets/widgetadmin.py
@@ -33,6 +33,7 @@ class SchoolAdmin(admin.ModelAdmin):
filter_vertical = ('students',)
filter_horizontal = ('alumni',)
+
site = WidgetAdmin(name='widget-admin')
site.register(models.User)
diff --git a/tests/auth_tests/test_admin_multidb.py b/tests/auth_tests/test_admin_multidb.py
index 6e2fb8d1b1..9d0d999739 100644
--- a/tests/auth_tests/test_admin_multidb.py
+++ b/tests/auth_tests/test_admin_multidb.py
@@ -15,6 +15,7 @@ class Router(object):
db_for_write = db_for_read
+
site = admin.AdminSite(name='test_adminsite')
site.register(User, admin_class=UserAdmin)
diff --git a/tests/auth_tests/urls_custom_user_admin.py b/tests/auth_tests/urls_custom_user_admin.py
index de33984fa5..94039dfa57 100644
--- a/tests/auth_tests/urls_custom_user_admin.py
+++ b/tests/auth_tests/urls_custom_user_admin.py
@@ -15,6 +15,7 @@ class CustomUserAdmin(UserAdmin):
super(CustomUserAdmin, self).log_change(request, object, message)
request.user.pk = original_pk
+
site.register(get_user_model(), CustomUserAdmin)
urlpatterns = [
diff --git a/tests/base/models.py b/tests/base/models.py
index f84d64df53..4a8a2ffd81 100644
--- a/tests/base/models.py
+++ b/tests/base/models.py
@@ -16,6 +16,7 @@ class CustomBaseModel(models.base.ModelBase):
class MyModel(six.with_metaclass(CustomBaseModel, models.Model)):
"""Model subclass with a custom base using six.with_metaclass."""
+
# This is done to ensure that for Python2 only, defining metaclasses
# still does not fail to create the model.
diff --git a/tests/check_framework/tests.py b/tests/check_framework/tests.py
index 4748f28eeb..26ce929655 100644
--- a/tests/check_framework/tests.py
+++ b/tests/check_framework/tests.py
@@ -137,12 +137,16 @@ def simple_system_check(**kwargs):
def tagged_system_check(**kwargs):
tagged_system_check.kwargs = kwargs
return [checks.Warning('System Check')]
+
+
tagged_system_check.tags = ['simpletag']
def deployment_system_check(**kwargs):
deployment_system_check.kwargs = kwargs
return [checks.Warning('Deployment Check')]
+
+
deployment_system_check.tags = ['deploymenttag']
diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py
index 8d8f03f101..f8f8f4dc0a 100644
--- a/tests/decorators/tests.py
+++ b/tests/decorators/tests.py
@@ -30,6 +30,8 @@ from django.views.decorators.vary import vary_on_cookie, vary_on_headers
def fully_decorated(request):
"""Expected __doc__"""
return HttpResponse('dummy')
+
+
fully_decorated.anything = "Expected __dict__"
@@ -170,6 +172,7 @@ def simple_dec(func):
return func("test:" + arg)
return wraps(func)(wrapper)
+
simple_dec_m = method_decorator(simple_dec)
@@ -180,6 +183,7 @@ def myattr_dec(func):
wrapper.myattr = True
return wraps(func)(wrapper)
+
myattr_dec_m = method_decorator(myattr_dec)
@@ -189,6 +193,7 @@ def myattr2_dec(func):
wrapper.myattr2 = True
return wraps(func)(wrapper)
+
myattr2_dec_m = method_decorator(myattr2_dec)
diff --git a/tests/dispatch/tests.py b/tests/dispatch/tests.py
index a50d31cabe..ce48157d70 100644
--- a/tests/dispatch/tests.py
+++ b/tests/dispatch/tests.py
@@ -35,6 +35,7 @@ class Callable(object):
def a(self, val, **kwargs):
return val
+
a_signal = Signal(providing_args=["val"])
b_signal = Signal(providing_args=["val"])
c_signal = Signal(providing_args=["val"])
diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py
index 724c16c4fa..8e04ce76cd 100644
--- a/tests/forms_tests/tests/test_formsets.py
+++ b/tests/forms_tests/tests/test_formsets.py
@@ -53,6 +53,7 @@ FavoriteDrinksFormSet = formset_factory(FavoriteDrinkForm, formset=BaseFavoriteD
class SplitDateTimeForm(Form):
when = SplitDateTimeField(initial=datetime.datetime.now)
+
SplitDateTimeFormSet = formset_factory(SplitDateTimeForm)
@@ -1281,6 +1282,7 @@ class ArticleForm(Form):
title = CharField()
pub_date = DateField()
+
ArticleFormSet = formset_factory(ArticleForm)
diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
index e1debb9d85..a25294beda 100644
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -397,6 +397,7 @@ class MockSuperUser(object):
def has_perm(self, perm):
return True
+
request = MockRequest()
request.user = MockSuperUser()
diff --git a/tests/generic_relations_regress/models.py b/tests/generic_relations_regress/models.py
index 331c5751a1..eb4f645d34 100644
--- a/tests/generic_relations_regress/models.py
+++ b/tests/generic_relations_regress/models.py
@@ -214,4 +214,5 @@ class Related(models.Model):
def prevent_deletes(sender, instance, **kwargs):
raise ProtectedError("Not allowed to delete.", [instance])
+
models.signals.pre_delete.connect(prevent_deletes, sender=Node)
diff --git a/tests/generic_views/models.py b/tests/generic_views/models.py
index afe4d042cd..a840df7d62 100644
--- a/tests/generic_views/models.py
+++ b/tests/generic_views/models.py
@@ -37,6 +37,7 @@ class DoesNotExistQuerySet(QuerySet):
def get(self, *args, **kwargs):
raise Author.DoesNotExist
+
DoesNotExistBookManager = BaseManager.from_queryset(DoesNotExistQuerySet)
diff --git a/tests/gis_tests/gdal_tests/test_srs.py b/tests/gis_tests/gdal_tests/test_srs.py
index 9c7f5c39a4..d03d8dcfd3 100644
--- a/tests/gis_tests/gdal_tests/test_srs.py
+++ b/tests/gis_tests/gdal_tests/test_srs.py
@@ -16,6 +16,7 @@ class TestSRS:
for key, value in kwargs.items():
setattr(self, key, value)
+
WGS84_proj = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs '
# Some Spatial Reference examples
diff --git a/tests/gis_tests/geoapp/feeds.py b/tests/gis_tests/geoapp/feeds.py
index 57d2d74866..4a0ec7647d 100644
--- a/tests/gis_tests/geoapp/feeds.py
+++ b/tests/gis_tests/geoapp/feeds.py
@@ -60,6 +60,7 @@ class TestW3CGeo3(TestGeoRSS1):
from django.contrib.gis.geos import Polygon
return Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))
+
# The feed dictionary to use for URLs.
feed_dict = {
'rss1': TestGeoRSS1,
diff --git a/tests/gis_tests/geos_tests/test_geos_mutation.py b/tests/gis_tests/geos_tests/test_geos_mutation.py
index b540fc1aa7..d2fd29bdb2 100644
--- a/tests/gis_tests/geos_tests/test_geos_mutation.py
+++ b/tests/gis_tests/geos_tests/test_geos_mutation.py
@@ -65,6 +65,7 @@ def api_get_area(x):
def api_get_length(x):
return x.length
+
geos_function_tests = [
val for name, val in vars().items()
if hasattr(val, '__call__') and name.startswith('api_get_')
diff --git a/tests/gis_tests/geos_tests/test_mutable_list.py b/tests/gis_tests/geos_tests/test_mutable_list.py
index 7eb3680b7c..3f7d8c30a1 100644
--- a/tests/gis_tests/geos_tests/test_mutable_list.py
+++ b/tests/gis_tests/geos_tests/test_mutable_list.py
@@ -51,6 +51,7 @@ def nextRange(length):
nextRange.start += 100
return range(nextRange.start, nextRange.start + length)
+
nextRange.start = 0
diff --git a/tests/gis_tests/test_measure.py b/tests/gis_tests/test_measure.py
index 174b04a29c..3616fcde1a 100644
--- a/tests/gis_tests/test_measure.py
+++ b/tests/gis_tests/test_measure.py
@@ -277,5 +277,6 @@ def suite():
def run(verbosity=2):
unittest.TextTestRunner(verbosity=verbosity).run(suite())
+
if __name__ == "__main__":
run()
diff --git a/tests/indexes/models.py b/tests/indexes/models.py
index abd3b0584a..47d413faee 100644
--- a/tests/indexes/models.py
+++ b/tests/indexes/models.py
@@ -45,6 +45,7 @@ class IndexTogetherSingleList(models.Model):
class Meta:
index_together = ["headline", "pub_date"]
+
# Indexing a TextField on Oracle or MySQL results in index creation error.
if connection.vendor == 'postgresql':
class IndexedArticle(models.Model):
diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py
index a46cad2f9a..c494a08ee4 100644
--- a/tests/logging_tests/tests.py
+++ b/tests/logging_tests/tests.py
@@ -385,6 +385,8 @@ class SettingsConfigTest(AdminScriptTestCase):
def dictConfig(config):
dictConfig.called = True
+
+
dictConfig.called = False
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py
index faa7d08189..cd0f53c4f2 100644
--- a/tests/model_fields/models.py
+++ b/tests/model_fields/models.py
@@ -218,6 +218,7 @@ class DataModel(models.Model):
class Document(models.Model):
myfile = models.FileField(upload_to='unused', unique=True)
+
###############################################################################
# ImageField
diff --git a/tests/model_options/models/tablespaces.py b/tests/model_options/models/tablespaces.py
index 42fe1356c8..ec705b7b2d 100644
--- a/tests/model_options/models/tablespaces.py
+++ b/tests/model_options/models/tablespaces.py
@@ -40,6 +40,7 @@ class Article(models.Model):
db_tablespace = 'tbl_tbsp'
managed = False
+
# Also set the tables for automatically created models
Authors = Article._meta.get_field('authors').remote_field.through
diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py
index c9bbfc8d0e..3ba497d100 100644
--- a/tests/modeladmin/tests.py
+++ b/tests/modeladmin/tests.py
@@ -30,6 +30,7 @@ class MockSuperUser(object):
def has_perm(self, perm):
return True
+
request = MockRequest()
request.user = MockSuperUser()
diff --git a/tests/serializers/test_data.py b/tests/serializers/test_data.py
index 4318856307..f9cb9582fe 100644
--- a/tests/serializers/test_data.py
+++ b/tests/serializers/test_data.py
@@ -182,6 +182,7 @@ def inherited_compare(testcase, pk, klass, data):
for key, value in data.items():
testcase.assertEqual(value, getattr(instance, key))
+
# Define some data types. Each data type is
# actually a pair of functions; one to create
# and one to compare objects of that type
diff --git a/tests/sitemaps_tests/urls/https.py b/tests/sitemaps_tests/urls/https.py
index ec4ab1489f..4f07d4759c 100644
--- a/tests/sitemaps_tests/urls/https.py
+++ b/tests/sitemaps_tests/urls/https.py
@@ -7,6 +7,7 @@ from .http import SimpleSitemap
class HTTPSSitemap(SimpleSitemap):
protocol = 'https'
+
secure_sitemaps = {
'simple': HTTPSSitemap,
}
diff --git a/tests/template_tests/templatetags/custom.py b/tests/template_tests/templatetags/custom.py
index ea1d7c6e67..fffef022ac 100644
--- a/tests/template_tests/templatetags/custom.py
+++ b/tests/template_tests/templatetags/custom.py
@@ -32,6 +32,8 @@ def context_stack_length(context):
def no_params():
"""Expected no_params __doc__"""
return "no_params - Expected result"
+
+
no_params.anything = "Expected no_params __dict__"
@@ -39,6 +41,8 @@ no_params.anything = "Expected no_params __dict__"
def one_param(arg):
"""Expected one_param __doc__"""
return "one_param - Expected result: %s" % arg
+
+
one_param.anything = "Expected one_param __dict__"
@@ -46,6 +50,8 @@ one_param.anything = "Expected one_param __dict__"
def explicit_no_context(arg):
"""Expected explicit_no_context __doc__"""
return "explicit_no_context - Expected result: %s" % arg
+
+
explicit_no_context.anything = "Expected explicit_no_context __dict__"
@@ -53,6 +59,8 @@ explicit_no_context.anything = "Expected explicit_no_context __dict__"
def no_params_with_context(context):
"""Expected no_params_with_context __doc__"""
return "no_params_with_context - Expected result (context value: %s)" % context['value']
+
+
no_params_with_context.anything = "Expected no_params_with_context __dict__"
@@ -60,6 +68,8 @@ no_params_with_context.anything = "Expected no_params_with_context __dict__"
def params_and_context(context, arg):
"""Expected params_and_context __doc__"""
return "params_and_context - Expected result (context value: %s): %s" % (context['value'], arg)
+
+
params_and_context.anything = "Expected params_and_context __dict__"
@@ -67,6 +77,8 @@ params_and_context.anything = "Expected params_and_context __dict__"
def simple_two_params(one, two):
"""Expected simple_two_params __doc__"""
return "simple_two_params - Expected result: %s, %s" % (one, two)
+
+
simple_two_params.anything = "Expected simple_two_params __dict__"
@@ -74,6 +86,8 @@ simple_two_params.anything = "Expected simple_two_params __dict__"
def simple_one_default(one, two='hi'):
"""Expected simple_one_default __doc__"""
return "simple_one_default - Expected result: %s, %s" % (one, two)
+
+
simple_one_default.anything = "Expected simple_one_default __dict__"
@@ -83,6 +97,8 @@ def simple_unlimited_args(one, two='hi', *args):
return "simple_unlimited_args - Expected result: %s" % (
', '.join(six.text_type(arg) for arg in [one, two] + list(args))
)
+
+
simple_unlimited_args.anything = "Expected simple_unlimited_args __dict__"
@@ -90,6 +106,8 @@ simple_unlimited_args.anything = "Expected simple_unlimited_args __dict__"
def simple_only_unlimited_args(*args):
"""Expected simple_only_unlimited_args __doc__"""
return "simple_only_unlimited_args - Expected result: %s" % ', '.join(six.text_type(arg) for arg in args)
+
+
simple_only_unlimited_args.anything = "Expected simple_only_unlimited_args __dict__"
@@ -102,6 +120,8 @@ def simple_unlimited_args_kwargs(one, two='hi', *args, **kwargs):
', '.join(six.text_type(arg) for arg in [one, two] + list(args)),
', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg)
)
+
+
simple_unlimited_args_kwargs.anything = "Expected simple_unlimited_args_kwargs __dict__"
@@ -109,6 +129,8 @@ simple_unlimited_args_kwargs.anything = "Expected simple_unlimited_args_kwargs _
def simple_tag_without_context_parameter(arg):
"""Expected simple_tag_without_context_parameter __doc__"""
return "Expected result"
+
+
simple_tag_without_context_parameter.anything = "Expected simple_tag_without_context_parameter __dict__"
@@ -144,6 +166,7 @@ def use_l10n(context):
def minustwo_overridden_name(value):
return value - 2
+
register.simple_tag(lambda x: x - 1, name='minusone')
diff --git a/tests/template_tests/templatetags/inclusion.py b/tests/template_tests/templatetags/inclusion.py
index 57fad868e7..dbdfa45c95 100644
--- a/tests/template_tests/templatetags/inclusion.py
+++ b/tests/template_tests/templatetags/inclusion.py
@@ -11,6 +11,8 @@ register = Library()
def inclusion_no_params():
"""Expected inclusion_no_params __doc__"""
return {"result": "inclusion_no_params - Expected result"}
+
+
inclusion_no_params.anything = "Expected inclusion_no_params __dict__"
@@ -18,6 +20,8 @@ inclusion_no_params.anything = "Expected inclusion_no_params __dict__"
def inclusion_no_params_from_template():
"""Expected inclusion_no_params_from_template __doc__"""
return {"result": "inclusion_no_params_from_template - Expected result"}
+
+
inclusion_no_params_from_template.anything = "Expected inclusion_no_params_from_template __dict__"
@@ -25,6 +29,8 @@ inclusion_no_params_from_template.anything = "Expected inclusion_no_params_from_
def inclusion_one_param(arg):
"""Expected inclusion_one_param __doc__"""
return {"result": "inclusion_one_param - Expected result: %s" % arg}
+
+
inclusion_one_param.anything = "Expected inclusion_one_param __dict__"
@@ -32,6 +38,8 @@ inclusion_one_param.anything = "Expected inclusion_one_param __dict__"
def inclusion_one_param_from_template(arg):
"""Expected inclusion_one_param_from_template __doc__"""
return {"result": "inclusion_one_param_from_template - Expected result: %s" % arg}
+
+
inclusion_one_param_from_template.anything = "Expected inclusion_one_param_from_template __dict__"
@@ -39,6 +47,8 @@ inclusion_one_param_from_template.anything = "Expected inclusion_one_param_from_
def inclusion_explicit_no_context(arg):
"""Expected inclusion_explicit_no_context __doc__"""
return {"result": "inclusion_explicit_no_context - Expected result: %s" % arg}
+
+
inclusion_explicit_no_context.anything = "Expected inclusion_explicit_no_context __dict__"
@@ -46,6 +56,8 @@ inclusion_explicit_no_context.anything = "Expected inclusion_explicit_no_context
def inclusion_explicit_no_context_from_template(arg):
"""Expected inclusion_explicit_no_context_from_template __doc__"""
return {"result": "inclusion_explicit_no_context_from_template - Expected result: %s" % arg}
+
+
inclusion_explicit_no_context_from_template.anything = "Expected inclusion_explicit_no_context_from_template __dict__"
@@ -53,6 +65,8 @@ inclusion_explicit_no_context_from_template.anything = "Expected inclusion_expli
def inclusion_no_params_with_context(context):
"""Expected inclusion_no_params_with_context __doc__"""
return {"result": "inclusion_no_params_with_context - Expected result (context value: %s)" % context['value']}
+
+
inclusion_no_params_with_context.anything = "Expected inclusion_no_params_with_context __dict__"
@@ -64,6 +78,8 @@ def inclusion_no_params_with_context_from_template(context):
"inclusion_no_params_with_context_from_template - Expected result (context value: %s)" % context['value']
)
}
+
+
inclusion_no_params_with_context_from_template.anything = (
"Expected inclusion_no_params_with_context_from_template __dict__"
)
@@ -75,6 +91,8 @@ def inclusion_params_and_context(context, arg):
return {
"result": "inclusion_params_and_context - Expected result (context value: %s): %s" % (context['value'], arg)
}
+
+
inclusion_params_and_context.anything = "Expected inclusion_params_and_context __dict__"
@@ -87,6 +105,8 @@ def inclusion_params_and_context_from_template(context, arg):
"(context value: %s): %s" % (context['value'], arg)
)
}
+
+
inclusion_params_and_context_from_template.anything = "Expected inclusion_params_and_context_from_template __dict__"
@@ -94,6 +114,8 @@ inclusion_params_and_context_from_template.anything = "Expected inclusion_params
def inclusion_two_params(one, two):
"""Expected inclusion_two_params __doc__"""
return {"result": "inclusion_two_params - Expected result: %s, %s" % (one, two)}
+
+
inclusion_two_params.anything = "Expected inclusion_two_params __dict__"
@@ -101,6 +123,8 @@ inclusion_two_params.anything = "Expected inclusion_two_params __dict__"
def inclusion_two_params_from_template(one, two):
"""Expected inclusion_two_params_from_template __doc__"""
return {"result": "inclusion_two_params_from_template - Expected result: %s, %s" % (one, two)}
+
+
inclusion_two_params_from_template.anything = "Expected inclusion_two_params_from_template __dict__"
@@ -108,6 +132,8 @@ inclusion_two_params_from_template.anything = "Expected inclusion_two_params_fro
def inclusion_one_default(one, two='hi'):
"""Expected inclusion_one_default __doc__"""
return {"result": "inclusion_one_default - Expected result: %s, %s" % (one, two)}
+
+
inclusion_one_default.anything = "Expected inclusion_one_default __dict__"
@@ -115,6 +141,8 @@ inclusion_one_default.anything = "Expected inclusion_one_default __dict__"
def inclusion_one_default_from_template(one, two='hi'):
"""Expected inclusion_one_default_from_template __doc__"""
return {"result": "inclusion_one_default_from_template - Expected result: %s, %s" % (one, two)}
+
+
inclusion_one_default_from_template.anything = "Expected inclusion_one_default_from_template __dict__"
@@ -128,6 +156,8 @@ def inclusion_unlimited_args(one, two='hi', *args):
)
)
}
+
+
inclusion_unlimited_args.anything = "Expected inclusion_unlimited_args __dict__"
@@ -141,6 +171,8 @@ def inclusion_unlimited_args_from_template(one, two='hi', *args):
)
)
}
+
+
inclusion_unlimited_args_from_template.anything = "Expected inclusion_unlimited_args_from_template __dict__"
@@ -152,6 +184,8 @@ def inclusion_only_unlimited_args(*args):
', '.join(six.text_type(arg) for arg in args)
)
}
+
+
inclusion_only_unlimited_args.anything = "Expected inclusion_only_unlimited_args __dict__"
@@ -163,6 +197,8 @@ def inclusion_only_unlimited_args_from_template(*args):
', '.join(six.text_type(arg) for arg in args)
)
}
+
+
inclusion_only_unlimited_args_from_template.anything = "Expected inclusion_only_unlimited_args_from_template __dict__"
@@ -170,6 +206,8 @@ inclusion_only_unlimited_args_from_template.anything = "Expected inclusion_only_
def inclusion_tag_use_l10n(context):
"""Expected inclusion_tag_use_l10n __doc__"""
return {}
+
+
inclusion_tag_use_l10n.anything = "Expected inclusion_tag_use_l10n __dict__"
@@ -182,6 +220,8 @@ def inclusion_unlimited_args_kwargs(one, two='hi', *args, **kwargs):
', '.join(six.text_type(arg) for arg in [one, two] + list(args)),
', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg)
)}
+
+
inclusion_unlimited_args_kwargs.anything = "Expected inclusion_unlimited_args_kwargs __dict__"
@@ -189,6 +229,8 @@ inclusion_unlimited_args_kwargs.anything = "Expected inclusion_unlimited_args_kw
def inclusion_tag_without_context_parameter(arg):
"""Expected inclusion_tag_without_context_parameter __doc__"""
return {}
+
+
inclusion_tag_without_context_parameter.anything = "Expected inclusion_tag_without_context_parameter __dict__"
diff --git a/tests/template_tests/templatetags/testtags.py b/tests/template_tests/templatetags/testtags.py
index 41b65a2ed1..4b839a9a54 100644
--- a/tests/template_tests/templatetags/testtags.py
+++ b/tests/template_tests/templatetags/testtags.py
@@ -14,6 +14,8 @@ class EchoNode(Node):
@register.tag
def echo(parser, token):
return EchoNode(token.contents.split()[1:])
+
+
register.tag('other_echo', echo)
diff --git a/tests/template_tests/test_response.py b/tests/template_tests/test_response.py
index 19e8e1fe99..c148b2dc44 100644
--- a/tests/template_tests/test_response.py
+++ b/tests/template_tests/test_response.py
@@ -19,6 +19,8 @@ from .utils import TEMPLATE_DIR
def test_processor(request):
return {'processors': 'yes'}
+
+
test_processor_name = 'template_tests.test_response.test_processor'
diff --git a/tests/test_client/views.py b/tests/test_client/views.py
index c1841c3c44..af30c4283d 100644
--- a/tests/test_client/views.py
+++ b/tests/test_client/views.py
@@ -116,6 +116,7 @@ def bad_view(request):
"A view that returns a 404 with some error content"
return HttpResponseNotFound('Not found!. This page contains some MAGIC content')
+
TestChoices = (
('a', 'First Choice'),
('b', 'Second Choice'),
@@ -191,6 +192,7 @@ class BaseTestFormSet(BaseFormSet):
)
emails.append(email)
+
TestFormSet = formset_factory(TestForm, BaseTestFormSet)
@@ -238,6 +240,8 @@ def _permission_protected_view(request):
name='Permissions Template')
c = Context({'user': request.user})
return HttpResponse(t.render(c))
+
+
permission_protected_view = permission_required('permission_not_granted')(_permission_protected_view)
permission_protected_view_exception = (
permission_required('permission_not_granted', raise_exception=True)(_permission_protected_view)
@@ -262,6 +266,7 @@ class _ViewManager(object):
c = Context({'user': request.user})
return HttpResponse(t.render(c))
+
_view_manager = _ViewManager()
login_protected_method_view = _view_manager.login_protected_view
permission_protected_method_view = _view_manager.permission_protected_view
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py
index a913e87d09..80ab0f38a5 100644
--- a/tests/test_runner/tests.py
+++ b/tests/test_runner/tests.py
@@ -135,6 +135,7 @@ class MockTestRunner(object):
def __init__(self, *args, **kwargs):
pass
+
MockTestRunner.run_tests = mock.Mock(return_value=[])
diff --git a/tests/timezones/admin.py b/tests/timezones/admin.py
index a650e110cc..4d3e4ca2fe 100644
--- a/tests/timezones/admin.py
+++ b/tests/timezones/admin.py
@@ -10,6 +10,7 @@ class EventAdmin(admin.ModelAdmin):
class TimestampAdmin(admin.ModelAdmin):
readonly_fields = ('created', 'updated')
+
site = admin.AdminSite(name='admin_tz')
site.register(Event, EventAdmin)
site.register(Timestamp, TimestampAdmin)
diff --git a/tests/urlpatterns_reverse/method_view_urls.py b/tests/urlpatterns_reverse/method_view_urls.py
index d2f24ecffa..c28958e6a9 100644
--- a/tests/urlpatterns_reverse/method_view_urls.py
+++ b/tests/urlpatterns_reverse/method_view_urls.py
@@ -9,6 +9,7 @@ class ViewContainer(object):
def classmethod_view(cls, request):
pass
+
view_container = ViewContainer()
diff --git a/tests/urlpatterns_reverse/urlconf_inner.py b/tests/urlpatterns_reverse/urlconf_inner.py
index 2a8ed7e26f..e2c7b7bf80 100644
--- a/tests/urlpatterns_reverse/urlconf_inner.py
+++ b/tests/urlpatterns_reverse/urlconf_inner.py
@@ -8,6 +8,7 @@ def inner_view(request):
'{% url "inner" as inner_url %}inner:{{ inner_url }}').render(Context())
return HttpResponse(content)
+
urlpatterns = [
url(r'^second_test/$', inner_view, name='inner'),
]
diff --git a/tests/urlpatterns_reverse/views.py b/tests/urlpatterns_reverse/views.py
index 1d1d3d557a..e8765367be 100644
--- a/tests/urlpatterns_reverse/views.py
+++ b/tests/urlpatterns_reverse/views.py
@@ -31,6 +31,7 @@ def pass_resolver_match_view(request, *args, **kwargs):
response.resolver_match = request.resolver_match
return response
+
uncallable = None # neither a callable nor a string
@@ -38,6 +39,7 @@ class ViewClass(object):
def __call__(self, request, *args, **kwargs):
return HttpResponse('')
+
view_class_instance = ViewClass()
diff --git a/tests/utils_tests/test_decorators.py b/tests/utils_tests/test_decorators.py
index 06c6dc1cd2..a4d080e2d7 100644
--- a/tests/utils_tests/test_decorators.py
+++ b/tests/utils_tests/test_decorators.py
@@ -9,6 +9,7 @@ class ProcessViewMiddleware(object):
def process_view(self, request, view_func, view_args, view_kwargs):
pass
+
process_view_dec = decorator_from_middleware(ProcessViewMiddleware)
@@ -21,6 +22,7 @@ class ClassProcessView(object):
def __call__(self, request):
return HttpResponse()
+
class_process_view = process_view_dec(ClassProcessView())
@@ -41,6 +43,7 @@ class FullMiddleware(object):
request.process_response_reached = True
return response
+
full_dec = decorator_from_middleware(FullMiddleware)
diff --git a/tests/utils_tests/test_jslex.py b/tests/utils_tests/test_jslex.py
index dbf0d41b77..f77be16b7f 100644
--- a/tests/utils_tests/test_jslex.py
+++ b/tests/utils_tests/test_jslex.py
@@ -123,6 +123,7 @@ def make_function(input, toks):
self.assertListEqual(result, toks)
return test_func
+
for i, (input, toks) in enumerate(JsTokensTest.LEX_CASES):
setattr(JsTokensTest, "test_case_%d" % i, make_function(input, toks))
@@ -224,5 +225,6 @@ def make_function(js, c):
self.assertMultiLineEqual(prepare_js_for_gettext(js), c)
return test_func
+
for i, pair in enumerate(GETTEXT_CASES):
setattr(JsToCForGettextTest, "test_case_%d" % i, make_function(*pair))
diff --git a/tests/utils_tests/test_module/__init__.py b/tests/utils_tests/test_module/__init__.py
index 8f33921eb6..29ee11b722 100644
--- a/tests/utils_tests/test_module/__init__.py
+++ b/tests/utils_tests/test_module/__init__.py
@@ -1,3 +1,5 @@
class SiteMock(object):
_registry = {}
+
+
site = SiteMock()
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index 2475131d28..4ef8a524b1 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -269,6 +269,7 @@ TEST_DATA = [
def create_path(filename):
return os.path.abspath(os.path.join(os.path.dirname(upath(__file__)), filename))
+
# Add valid and invalid URL tests.
# This only tests the validator without extended schemes.
with io.open(create_path('valid_urls.txt'), encoding='utf8') as f:
@@ -340,6 +341,7 @@ class TestSimpleValidators(SimpleTestCase):
with self.assertRaisesMessage(ValidationError, '"djangoproject.com" has more than 16 characters.'):
v('djangoproject.com')
+
test_counter = 0
for validator, value, expected in TEST_DATA:
name, method = create_simple_test_method(validator, expected, value, test_counter)
diff --git a/tests/view_tests/__init__.py b/tests/view_tests/__init__.py
index 371ab40b40..638df1b91a 100644
--- a/tests/view_tests/__init__.py
+++ b/tests/view_tests/__init__.py
@@ -5,6 +5,7 @@ from __future__ import unicode_literals
class BrokenException(Exception):
pass
+
except_args = (b'Broken!', # plain exception with ASCII text
'¡Broken!', # non-ASCII unicode data
'¡Broken!'.encode('utf-8'), # non-ASCII, utf-8 encoded bytestring
diff --git a/tests/wsgi/urls.py b/tests/wsgi/urls.py
index 1d7f91b689..6d4a3b6b4a 100644
--- a/tests/wsgi/urls.py
+++ b/tests/wsgi/urls.py
@@ -5,6 +5,7 @@ from django.http import FileResponse, HttpResponse
def helloworld(request):
return HttpResponse("Hello World!")
+
urlpatterns = [
url("^$", helloworld),
url(r'^file/$', lambda x: FileResponse(open(__file__, 'rb'))),