Fixed E221 pep8 warnings.

This commit is contained in:
Tim Graham 2013-10-22 09:31:43 -04:00
parent 0d0f4f020a
commit 1597503a01
30 changed files with 94 additions and 90 deletions

View File

@ -134,8 +134,8 @@ def result_headers(cl):
# build new ordering param # build new ordering param
o_list_primary = [] # URL for making this field the primary sort o_list_primary = [] # URL for making this field the primary sort
o_list_remove = [] # URL for removing this field from sort o_list_remove = [] # URL for removing this field from sort
o_list_toggle = [] # URL for toggling order type for this field o_list_toggle = [] # URL for toggling order type for this field
make_qs_param = lambda t, n: ('-' if t == 'desc' else '') + str(n) make_qs_param = lambda t, n: ('-' if t == 'desc' else '') + str(n)
for j, ot in ordering_field_columns.items(): for j, ot in ordering_field_columns.items():

View File

@ -204,7 +204,13 @@ def model_detail(request, app_label, model_name):
if isinstance(field, models.ForeignKey): if isinstance(field, models.ForeignKey):
data_type = field.rel.to.__name__ data_type = field.rel.to.__name__
app_label = field.rel.to._meta.app_label app_label = field.rel.to._meta.app_label
verbose = utils.parse_rst((_("the related `%(app_label)s.%(data_type)s` object") % {'app_label': app_label, 'data_type': data_type}), 'model', _('model:') + data_type) verbose = utils.parse_rst(
(_("the related `%(app_label)s.%(data_type)s` object") % {
'app_label': app_label, 'data_type': data_type,
}),
'model',
_('model:') + data_type,
)
else: else:
data_type = get_readable_field_data_type(field) data_type = get_readable_field_data_type(field)
verbose = field.verbose_name verbose = field.verbose_name

View File

@ -275,7 +275,6 @@ class TestUtilsHashPass(unittest.TestCase):
finally: finally:
hasher.iterations = old_iterations hasher.iterations = old_iterations
def test_load_library_no_algorithm(self): def test_load_library_no_algorithm(self):
with self.assertRaises(ValueError) as e: with self.assertRaises(ValueError) as e:
BasePasswordHasher()._load_library() BasePasswordHasher()._load_library()

View File

@ -678,7 +678,7 @@ class GeoQuerySet(QuerySet):
procedure_fmt += ', %s(%%%%s, %s)' % (backend.transform, self.query.transformed_srid) procedure_fmt += ', %s(%%%%s, %s)' % (backend.transform, self.query.transformed_srid)
else: else:
# `transform()` was not used on this GeoQuerySet. # `transform()` was not used on this GeoQuerySet.
procedure_fmt = '%(geo_col)s,%(geom)s' procedure_fmt = '%(geo_col)s,%(geom)s'
if not geography and geodetic: if not geography and geodetic:
# Spherical distance calculation is needed (because the geographic # Spherical distance calculation is needed (because the geographic

View File

@ -41,11 +41,11 @@ class GeoIP(object):
# #
# GEOIP_MMAP_CACHE - load database into mmap shared memory ( not available # GEOIP_MMAP_CACHE - load database into mmap shared memory ( not available
# on Windows). # on Windows).
GEOIP_STANDARD = 0 GEOIP_STANDARD = 0
GEOIP_MEMORY_CACHE = 1 GEOIP_MEMORY_CACHE = 1
GEOIP_CHECK_CACHE = 2 GEOIP_CHECK_CACHE = 2
GEOIP_INDEX_CACHE = 4 GEOIP_INDEX_CACHE = 4
GEOIP_MMAP_CACHE = 8 GEOIP_MMAP_CACHE = 8
cache_options = dict((opt, None) for opt in (0, 1, 2, 4, 8)) cache_options = dict((opt, None) for opt in (0, 1, 2, 4, 8))
# Paths to the city & country binary databases. # Paths to the city & country binary databases.

View File

@ -100,7 +100,7 @@ class GEOSContextHandle_t(Structure):
GEOM_PTR = POINTER(GEOSGeom_t) GEOM_PTR = POINTER(GEOSGeom_t)
PREPGEOM_PTR = POINTER(GEOSPrepGeom_t) PREPGEOM_PTR = POINTER(GEOSPrepGeom_t)
CS_PTR = POINTER(GEOSCoordSeq_t) CS_PTR = POINTER(GEOSCoordSeq_t)
CONTEXT_PTR = POINTER(GEOSContextHandle_t) CONTEXT_PTR = POINTER(GEOSContextHandle_t)
# Used specifically by the GEOSGeom_createPolygon and GEOSGeom_createCollection # Used specifically by the GEOSGeom_createPolygon and GEOSGeom_createCollection
# GEOS routines # GEOS routines

View File

@ -88,17 +88,17 @@ class ListMixin(object):
raise TypeError("%s is not a legal index" % index) raise TypeError("%s is not a legal index" % index)
# calculate new length and dimensions # calculate new length and dimensions
origLen = len(self) origLen = len(self)
if isinstance(index, six.integer_types): if isinstance(index, six.integer_types):
index = self._checkindex(index) index = self._checkindex(index)
indexRange = [index] indexRange = [index]
else: else:
indexRange = range(*index.indices(origLen)) indexRange = range(*index.indices(origLen))
newLen = origLen - len(indexRange) newLen = origLen - len(indexRange)
newItems = (self._get_single_internal(i) newItems = (self._get_single_internal(i)
for i in xrange(origLen) for i in xrange(origLen)
if i not in indexRange) if i not in indexRange)
self._rebuild(newLen, newItems) self._rebuild(newLen, newItems)
@ -268,8 +268,8 @@ class ListMixin(object):
self._check_allowed(values) self._check_allowed(values)
origLen = len(self) origLen = len(self)
valueList = list(values) valueList = list(values)
start, stop, step = index.indices(origLen) start, stop, step = index.indices(origLen)
# CAREFUL: index.step and step are not the same! # CAREFUL: index.step and step are not the same!
@ -281,7 +281,7 @@ class ListMixin(object):
def _assign_extended_slice_rebuild(self, start, stop, step, valueList): def _assign_extended_slice_rebuild(self, start, stop, step, valueList):
'Assign an extended slice by rebuilding entire list' 'Assign an extended slice by rebuilding entire list'
indexList = range(start, stop, step) indexList = range(start, stop, step)
# extended slice, only allow assigning slice of same size # extended slice, only allow assigning slice of same size
if len(valueList) != len(indexList): if len(valueList) != len(indexList):
raise ValueError('attempt to assign sequence of size %d ' raise ValueError('attempt to assign sequence of size %d '
@ -289,7 +289,7 @@ class ListMixin(object):
% (len(valueList), len(indexList))) % (len(valueList), len(indexList)))
# we're not changing the length of the sequence # we're not changing the length of the sequence
newLen = len(self) newLen = len(self)
newVals = dict(zip(indexList, valueList)) newVals = dict(zip(indexList, valueList))
def newItems(): def newItems():
for i in xrange(newLen): for i in xrange(newLen):
@ -302,7 +302,7 @@ class ListMixin(object):
def _assign_extended_slice(self, start, stop, step, valueList): def _assign_extended_slice(self, start, stop, step, valueList):
'Assign an extended slice by re-assigning individual items' 'Assign an extended slice by re-assigning individual items'
indexList = range(start, stop, step) indexList = range(start, stop, step)
# extended slice, only allow assigning slice of same size # extended slice, only allow assigning slice of same size
if len(valueList) != len(indexList): if len(valueList) != len(indexList):
raise ValueError('attempt to assign sequence of size %d ' raise ValueError('attempt to assign sequence of size %d '
@ -316,7 +316,7 @@ class ListMixin(object):
'Assign a simple slice; Can assign slice of any length' 'Assign a simple slice; Can assign slice of any length'
origLen = len(self) origLen = len(self)
stop = max(start, stop) stop = max(start, stop)
newLen = origLen - stop + start + len(valueList) newLen = origLen - stop + start + len(valueList)
def newItems(): def newItems():
for i in xrange(origLen + 1): for i in xrange(origLen + 1):
if i == start: if i == start:

View File

@ -37,11 +37,11 @@ class Polygon(GEOSGeometry):
# If initialized as Polygon(shell, (LinearRing, LinearRing)) [for backward-compatibility] # If initialized as Polygon(shell, (LinearRing, LinearRing)) [for backward-compatibility]
if n_holes == 1 and isinstance(init_holes[0], (tuple, list)): if n_holes == 1 and isinstance(init_holes[0], (tuple, list)):
if len(init_holes[0]) == 0: if len(init_holes[0]) == 0:
init_holes = () init_holes = ()
n_holes = 0 n_holes = 0
elif isinstance(init_holes[0][0], LinearRing): elif isinstance(init_holes[0][0], LinearRing):
init_holes = init_holes[0] init_holes = init_holes[0]
n_holes = len(init_holes) n_holes = len(init_holes)
polygon = self._create_polygon(n_holes + 1, (ext_ring,) + init_holes) polygon = self._create_polygon(n_holes + 1, (ext_ring,) + init_holes)
super(Polygon, self).__init__(polygon, **kwargs) super(Polygon, self).__init__(polygon, **kwargs)

View File

@ -23,9 +23,9 @@ class WKBReader_st(Structure):
class WKBWriter_st(Structure): class WKBWriter_st(Structure):
pass pass
WKT_READ_PTR = POINTER(WKTReader_st) WKT_READ_PTR = POINTER(WKTReader_st)
WKT_WRITE_PTR = POINTER(WKTWriter_st) WKT_WRITE_PTR = POINTER(WKTWriter_st)
WKB_READ_PTR = POINTER(WKBReader_st) WKB_READ_PTR = POINTER(WKBReader_st)
WKB_WRITE_PTR = POINTER(WKBReader_st) WKB_WRITE_PTR = POINTER(WKBReader_st)
### WKTReader routines ### ### WKTReader routines ###
@ -114,8 +114,8 @@ def wkb_writer_set(func, argtype=c_int):
wkb_writer_get_byteorder = wkb_writer_get(GEOSFunc('GEOSWKBWriter_getByteOrder')) wkb_writer_get_byteorder = wkb_writer_get(GEOSFunc('GEOSWKBWriter_getByteOrder'))
wkb_writer_set_byteorder = wkb_writer_set(GEOSFunc('GEOSWKBWriter_setByteOrder')) wkb_writer_set_byteorder = wkb_writer_set(GEOSFunc('GEOSWKBWriter_setByteOrder'))
wkb_writer_get_outdim = wkb_writer_get(GEOSFunc('GEOSWKBWriter_getOutputDimension')) wkb_writer_get_outdim = wkb_writer_get(GEOSFunc('GEOSWKBWriter_getOutputDimension'))
wkb_writer_set_outdim = wkb_writer_set(GEOSFunc('GEOSWKBWriter_setOutputDimension')) wkb_writer_set_outdim = wkb_writer_set(GEOSFunc('GEOSWKBWriter_setOutputDimension'))
wkb_writer_get_include_srid = wkb_writer_get(GEOSFunc('GEOSWKBWriter_getIncludeSRID'), restype=c_char) wkb_writer_get_include_srid = wkb_writer_get(GEOSFunc('GEOSWKBWriter_getIncludeSRID'), restype=c_char)
wkb_writer_set_include_srid = wkb_writer_set(GEOSFunc('GEOSWKBWriter_setIncludeSRID'), argtype=c_char) wkb_writer_set_include_srid = wkb_writer_set(GEOSFunc('GEOSWKBWriter_setIncludeSRID'), argtype=c_char)

View File

@ -20,8 +20,8 @@ class GoogleMap(object):
# String constants # String constants
onunload = mark_safe('onunload="GUnload()"') # Cleans up after Google Maps onunload = mark_safe('onunload="GUnload()"') # Cleans up after Google Maps
vml_css = mark_safe('v\:* {behavior:url(#default#VML);}') # CSS for IE VML vml_css = mark_safe('v\:* {behavior:url(#default#VML);}') # CSS for IE VML
xmlns = mark_safe('xmlns:v="urn:schemas-microsoft-com:vml"') # XML Namespace (for IE VML). xmlns = mark_safe('xmlns:v="urn:schemas-microsoft-com:vml"') # XML Namespace (for IE VML).
def __init__(self, key=None, api_url=None, version=None, def __init__(self, key=None, api_url=None, version=None,
center=None, zoom=None, dom_id='map', center=None, zoom=None, dom_id='map',

View File

@ -34,7 +34,7 @@ class GoogleZoom(object):
# zoom levels. # zoom levels.
self._degpp = [] # Degrees per pixel self._degpp = [] # Degrees per pixel
self._radpp = [] # Radians per pixel self._radpp = [] # Radians per pixel
self._npix = [] # 1/2 the number of pixels for a tile at the given zoom level self._npix = [] # 1/2 the number of pixels for a tile at the given zoom level
# Incrementing through the zoom levels and populating the parameter arrays. # Incrementing through the zoom levels and populating the parameter arrays.
z = tilesize # The number of pixels per zoom level. z = tilesize # The number of pixels per zoom level.
@ -158,5 +158,5 @@ class GoogleZoom(object):
ur = Point(extent[2:]) ur = Point(extent[2:])
# Calculating the width and height. # Calculating the width and height.
height = ll.distance(ul) height = ll.distance(ul)
width = ul.distance(ur) width = ul.distance(ur)
return width, height return width, height

View File

@ -51,8 +51,8 @@ def pretty_name(obj):
@total_ordering @total_ordering
class MeasureBase(object): class MeasureBase(object):
STANDARD_UNIT = None STANDARD_UNIT = None
ALIAS = {} ALIAS = {}
UNITS = {} UNITS = {}
LALIAS = {} LALIAS = {}
def __init__(self, default_unit=None, **kwargs): def __init__(self, default_unit=None, **kwargs):

View File

@ -118,7 +118,7 @@ class GeoModelTest(TestCase):
# San Antonio in 'Texas 4205, Southern Zone (1983, meters)' (SRID 41157) # San Antonio in 'Texas 4205, Southern Zone (1983, meters)' (SRID 41157)
# Used the following Oracle SQL to get this value: # Used the following Oracle SQL to get this value:
# SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_CS.TRANSFORM(SDO_GEOMETRY('POINT (-98.493183 29.424170)', 4326), 41157)) FROM DUAL; # SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_CS.TRANSFORM(SDO_GEOMETRY('POINT (-98.493183 29.424170)', 4326), 41157)) FROM DUAL;
nad_wkt = 'POINT (300662.034646583 5416427.45974934)' nad_wkt = 'POINT (300662.034646583 5416427.45974934)'
nad_srid = 41157 nad_srid = 41157
else: else:
# San Antonio in 'NAD83(HARN) / Texas Centric Lambert Conformal' (SRID 3084) # San Antonio in 'NAD83(HARN) / Texas Centric Lambert Conformal' (SRID 3084)

View File

@ -31,8 +31,8 @@ inter_shp = os.path.join(shp_path, 'interstates', 'interstates.shp')
invalid_shp = os.path.join(shp_path, 'invalid', 'emptypoints.shp') invalid_shp = os.path.join(shp_path, 'invalid', 'emptypoints.shp')
# Dictionaries to hold what's expected in the county shapefile. # Dictionaries to hold what's expected in the county shapefile.
NAMES = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo'] NAMES = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo']
NUMS = [1, 2, 1, 19, 1] # Number of polygons for each. NUMS = [1, 2, 1, 19, 1] # Number of polygons for each.
STATES = ['Texas', 'Texas', 'Texas', 'Hawaii', 'Colorado'] STATES = ['Texas', 'Texas', 'Texas', 'Hawaii', 'Colorado']

View File

@ -30,9 +30,9 @@ def no_spatialite(func):
# Shortcut booleans to omit only portions of tests. # Shortcut booleans to omit only portions of tests.
_default_db = settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] _default_db = settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1]
oracle = _default_db == 'oracle' oracle = _default_db == 'oracle'
postgis = _default_db == 'postgis' postgis = _default_db == 'postgis'
mysql = _default_db == 'mysql' mysql = _default_db == 'mysql'
spatialite = _default_db == 'spatialite' spatialite = _default_db == 'spatialite'
HAS_SPATIALREFSYS = True HAS_SPATIALREFSYS = True

View File

@ -57,9 +57,9 @@ class BaseTests(object):
def setUp(self): def setUp(self):
self.settings_override = override_settings_tags( self.settings_override = override_settings_tags(
TEMPLATE_DIRS = (), TEMPLATE_DIRS = (),
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS, TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS,
MESSAGE_TAGS = '', MESSAGE_TAGS = '',
MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__, MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__,
self.storage_class.__name__), self.storage_class.__name__),
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer', SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer',

View File

@ -229,7 +229,7 @@ class TemplateCommand(BaseCommand):
tmp = url.rstrip('/') tmp = url.rstrip('/')
filename = tmp.split('/')[-1] filename = tmp.split('/')[-1]
if url.endswith('/'): if url.endswith('/'):
display_url = tmp + '/' display_url = tmp + '/'
else: else:
display_url = url display_url = url
return filename, display_url return filename, display_url

View File

@ -194,10 +194,10 @@ def linenumbers(value, autoescape=None):
width = six.text_type(len(six.text_type(len(lines)))) width = six.text_type(len(six.text_type(len(lines))))
if not autoescape or isinstance(value, SafeData): if not autoescape or isinstance(value, SafeData):
for i, line in enumerate(lines): for i, line in enumerate(lines):
lines[i] = ("%0" + width + "d. %s") % (i + 1, line) lines[i] = ("%0" + width + "d. %s") % (i + 1, line)
else: else:
for i, line in enumerate(lines): for i, line in enumerate(lines):
lines[i] = ("%0" + width + "d. %s") % (i + 1, escape(line)) lines[i] = ("%0" + width + "d. %s") % (i + 1, escape(line))
return mark_safe('\n'.join(lines)) return mark_safe('\n'.join(lines))
@register.filter(is_safe=True) @register.filter(is_safe=True)

View File

@ -490,19 +490,19 @@ class ImmutableList(tuple):
raise AttributeError(self.warning) raise AttributeError(self.warning)
# All list mutation functions complain. # All list mutation functions complain.
__delitem__ = complain __delitem__ = complain
__delslice__ = complain __delslice__ = complain
__iadd__ = complain __iadd__ = complain
__imul__ = complain __imul__ = complain
__setitem__ = complain __setitem__ = complain
__setslice__ = complain __setslice__ = complain
append = complain append = complain
extend = complain extend = complain
insert = complain insert = complain
pop = complain pop = complain
remove = complain remove= complain
sort = complain sort = complain
reverse = complain reverse = complain
class DictWrapper(dict): class DictWrapper(dict):
""" """

View File

@ -27,11 +27,11 @@ class RWLock(object):
writer_leaves() writer_leaves()
""" """
def __init__(self): def __init__(self):
self.mutex = threading.RLock() self.mutex = threading.RLock()
self.can_read = threading.Semaphore(0) self.can_read = threading.Semaphore(0)
self.can_write = threading.Semaphore(0) self.can_write = threading.Semaphore(0)
self.active_readers = 0 self.active_readers = 0
self.active_writers = 0 self.active_writers = 0
self.waiting_readers = 0 self.waiting_readers = 0
self.waiting_writers = 0 self.waiting_writers = 0
@ -48,7 +48,7 @@ class RWLock(object):
with self.mutex: with self.mutex:
self.active_readers -= 1 self.active_readers -= 1
if self.active_readers == 0 and self.waiting_writers != 0: if self.active_readers == 0 and self.waiting_writers != 0:
self.active_writers += 1 self.active_writers += 1
self.waiting_writers -= 1 self.waiting_writers -= 1
self.can_write.release() self.can_write.release()
@ -73,7 +73,7 @@ class RWLock(object):
with self.mutex: with self.mutex:
self.active_writers -= 1 self.active_writers -= 1
if self.waiting_writers != 0: if self.waiting_writers != 0:
self.active_writers += 1 self.active_writers += 1
self.waiting_writers -= 1 self.waiting_writers -= 1
self.can_write.release() self.can_write.release()
elif self.waiting_readers != 0: elif self.waiting_readers != 0:

View File

@ -22,35 +22,35 @@ simple_option_desc_re = re.compile(
def setup(app): def setup(app):
app.add_crossref_type( app.add_crossref_type(
directivename = "setting", directivename = "setting",
rolename = "setting", rolename = "setting",
indextemplate = "pair: %s; setting", indextemplate = "pair: %s; setting",
) )
app.add_crossref_type( app.add_crossref_type(
directivename = "templatetag", directivename = "templatetag",
rolename = "ttag", rolename = "ttag",
indextemplate = "pair: %s; template tag" indextemplate = "pair: %s; template tag"
) )
app.add_crossref_type( app.add_crossref_type(
directivename = "templatefilter", directivename = "templatefilter",
rolename = "tfilter", rolename = "tfilter",
indextemplate = "pair: %s; template filter" indextemplate = "pair: %s; template filter"
) )
app.add_crossref_type( app.add_crossref_type(
directivename = "fieldlookup", directivename = "fieldlookup",
rolename = "lookup", rolename = "lookup",
indextemplate = "pair: %s; field lookup type", indextemplate = "pair: %s; field lookup type",
) )
app.add_description_unit( app.add_description_unit(
directivename = "django-admin", directivename = "django-admin",
rolename = "djadmin", rolename = "djadmin",
indextemplate = "pair: %s; django-admin command", indextemplate = "pair: %s; django-admin command",
parse_node = parse_django_admin_node, parse_node = parse_django_admin_node,
) )
app.add_description_unit( app.add_description_unit(
directivename = "django-admin-option", directivename = "django-admin-option",
rolename = "djadminopt", rolename = "djadminopt",
indextemplate = "pair: %s; django-admin command-line option", indextemplate = "pair: %s; django-admin command-line option",
parse_node = parse_django_adminopt_node, parse_node = parse_django_adminopt_node,
) )
app.add_config_value('django_next_version', '0.0', True) app.add_config_value('django_next_version', '0.0', True)
app.add_directive('versionadded', VersionDirective) app.add_directive('versionadded', VersionDirective)

View File

@ -4,7 +4,7 @@ install-script = scripts/rpm-install.sh
[flake8] [flake8]
exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py
ignore=E124,E125,E127,E128,E225,E226,E241,E251,E302,E501,E203,E221,E231,E261,E301,F401,F403,W601 ignore=E124,E125,E127,E128,E225,E226,E241,E251,E302,E501,E203,E231,E261,E301,F401,F403,W601
[metadata] [metadata]
license-file = LICENSE license-file = LICENSE

View File

@ -22,7 +22,6 @@ from .models import Article, Count, Event, Location, EventGuide
class NestedObjectsTests(TestCase): class NestedObjectsTests(TestCase):
""" """
Tests for ``NestedObject`` utility collection. Tests for ``NestedObject`` utility collection.
""" """
def setUp(self): def setUp(self):
self.n = NestedObjects(using=DEFAULT_DB_ALIAS) self.n = NestedObjects(using=DEFAULT_DB_ALIAS)
@ -295,7 +294,7 @@ class UtilTests(SimpleTestCase):
# safestring should not be escaped # safestring should not be escaped
class MyForm(forms.Form): class MyForm(forms.Form):
text = forms.CharField(label=mark_safe('<i>text</i>')) text = forms.CharField(label=mark_safe('<i>text</i>'))
cb = forms.BooleanField(label=mark_safe('<i>cb</i>')) cb = forms.BooleanField(label=mark_safe('<i>cb</i>'))
form = MyForm() form = MyForm()
self.assertHTMLEqual(helpers.AdminField(form, 'text', is_first=False).label_tag(), self.assertHTMLEqual(helpers.AdminField(form, 'text', is_first=False).label_tag(),
@ -306,7 +305,7 @@ class UtilTests(SimpleTestCase):
# normal strings needs to be escaped # normal strings needs to be escaped
class MyForm(forms.Form): class MyForm(forms.Form):
text = forms.CharField(label='&text') text = forms.CharField(label='&text')
cb = forms.BooleanField(label='&cb') cb = forms.BooleanField(label='&cb')
form = MyForm() form = MyForm()
self.assertHTMLEqual(helpers.AdminField(form, 'text', is_first=False).label_tag(), self.assertHTMLEqual(helpers.AdminField(form, 'text', is_first=False).label_tag(),

View File

@ -1190,16 +1190,16 @@ class LocaleMiddlewareTests(TransRealMixin, TestCase):
# Clear the session data before request # Clear the session data before request
session.save() session.save()
response = self.client.get('/en/simple/') self.client.get('/en/simple/')
self.assertEqual(self.client.session['_language'], 'en') self.assertEqual(self.client.session['_language'], 'en')
# Clear the session data before request # Clear the session data before request
session.save() session.save()
response = self.client.get('/fr/simple/') self.client.get('/fr/simple/')
self.assertEqual(self.client.session['_language'], 'fr') self.assertEqual(self.client.session['_language'], 'fr')
# Check that language is not changed in session # Check that language is not changed in session
response = self.client.get('/en/simple/') self.client.get('/en/simple/')
self.assertEqual(self.client.session['_language'], 'fr') self.assertEqual(self.client.session['_language'], 'fr')
@override_settings( @override_settings(
@ -1221,7 +1221,7 @@ class LocaleMiddlewareTests(TransRealMixin, TestCase):
self.client.cookies[settings.SESSION_COOKIE_NAME] = session.session_key self.client.cookies[settings.SESSION_COOKIE_NAME] = session.session_key
# request other language; should default to old language key value # request other language; should default to old language key value
response = self.client.get('/fr/simple/') self.client.get('/fr/simple/')
self.assertEqual(self.client.session['_language'], 'en') self.assertEqual(self.client.session['_language'], 'en')

View File

@ -98,7 +98,7 @@ class M2MThroughTestCase(TestCase):
def test_join_trimming(self): def test_join_trimming(self):
"Check that we don't involve too many copies of the intermediate table when doing a join. Refs #8046, #8254" "Check that we don't involve too many copies of the intermediate table when doing a join. Refs #8046, #8254"
bob = Person.objects.create(name="Bob") bob = Person.objects.create(name="Bob")
jim = Person.objects.create(name="Jim") jim = Person.objects.create(name="Jim")
rock = Group.objects.create(name="Rock") rock = Group.objects.create(name="Rock")

View File

@ -466,7 +466,7 @@ class ModelFormsetTest(TestCase):
formset = AuthorBooksFormSet(instance=author) formset = AuthorBooksFormSet(instance=author)
self.assertEqual(len(formset.forms), 3) self.assertEqual(len(formset.forms), 3)
self.assertHTMLEqual(formset.forms[0].as_p(), self.assertHTMLEqual(formset.forms[0].as_p(),
'<p><label for="id_book_set-0-title">Title:</label> <input id="id_book_set-0-title" type="text" name="book_set-0-title" maxlength="100" /><input type="hidden" name="book_set-0-author" value="%d" id="id_book_set-0-author" /><input type="hidden" name="book_set-0-id" id="id_book_set-0-id" /></p>' % author.id) '<p><label for="id_book_set-0-title">Title:</label> <input id="id_book_set-0-title" type="text" name="book_set-0-title" maxlength="100" /><input type="hidden" name="book_set-0-author" value="%d" id="id_book_set-0-author" /><input type="hidden" name="book_set-0-id" id="id_book_set-0-id" /></p>' % author.id)
self.assertHTMLEqual(formset.forms[1].as_p(), self.assertHTMLEqual(formset.forms[1].as_p(),
'<p><label for="id_book_set-1-title">Title:</label> <input id="id_book_set-1-title" type="text" name="book_set-1-title" maxlength="100" /><input type="hidden" name="book_set-1-author" value="%d" id="id_book_set-1-author" /><input type="hidden" name="book_set-1-id" id="id_book_set-1-id" /></p>' % author.id) '<p><label for="id_book_set-1-title">Title:</label> <input id="id_book_set-1-title" type="text" name="book_set-1-title" maxlength="100" /><input type="hidden" name="book_set-1-author" value="%d" id="id_book_set-1-author" /><input type="hidden" name="book_set-1-id" id="id_book_set-1-id" /></p>' % author.id)
self.assertHTMLEqual(formset.forms[2].as_p(), self.assertHTMLEqual(formset.forms[2].as_p(),

View File

@ -1864,7 +1864,7 @@ class SyncOnlyDefaultDatabaseRouter(object):
class MigrateTestCase(TestCase): class MigrateTestCase(TestCase):
available_apps = [ available_apps = [
'multiple_database', 'multiple_database',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes' 'django.contrib.contenttypes'

View File

@ -147,8 +147,8 @@ class Comment(models.Model):
comment = models.TextField() comment = models.TextField()
# Content-object field # Content-object field
content_type = models.ForeignKey(ContentType) content_type = models.ForeignKey(ContentType)
object_pk = models.TextField() object_pk = models.TextField()
content_object = generic.GenericForeignKey(ct_field="content_type", fk_field="object_pk") content_object = generic.GenericForeignKey(ct_field="content_type", fk_field="object_pk")

View File

@ -1437,7 +1437,7 @@ class Queries4Tests(BaseQuerysetTest):
self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False) self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False)
def test_ticket15316_one2one_filter_false(self): def test_ticket15316_one2one_filter_false(self):
c = SimpleCategory.objects.create(name="cat") c = SimpleCategory.objects.create(name="cat")
c0 = SimpleCategory.objects.create(name="cat0") c0 = SimpleCategory.objects.create(name="cat0")
c1 = SimpleCategory.objects.create(name="category1") c1 = SimpleCategory.objects.create(name="category1")
@ -1453,7 +1453,7 @@ class Queries4Tests(BaseQuerysetTest):
self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False) self.assertQuerysetEqual(qs, [ci2.pk, ci3.pk], lambda x: x.pk, False)
def test_ticket15316_one2one_exclude_false(self): def test_ticket15316_one2one_exclude_false(self):
c = SimpleCategory.objects.create(name="cat") c = SimpleCategory.objects.create(name="cat")
c0 = SimpleCategory.objects.create(name="cat0") c0 = SimpleCategory.objects.create(name="cat0")
c1 = SimpleCategory.objects.create(name="category1") c1 = SimpleCategory.objects.create(name="category1")
@ -1469,7 +1469,7 @@ class Queries4Tests(BaseQuerysetTest):
self.assertQuerysetEqual(qs, [ci1.pk], lambda x: x.pk) self.assertQuerysetEqual(qs, [ci1.pk], lambda x: x.pk)
def test_ticket15316_one2one_filter_true(self): def test_ticket15316_one2one_filter_true(self):
c = SimpleCategory.objects.create(name="cat") c = SimpleCategory.objects.create(name="cat")
c0 = SimpleCategory.objects.create(name="cat0") c0 = SimpleCategory.objects.create(name="cat0")
c1 = SimpleCategory.objects.create(name="category1") c1 = SimpleCategory.objects.create(name="category1")
@ -1485,7 +1485,7 @@ class Queries4Tests(BaseQuerysetTest):
self.assertQuerysetEqual(qs, [ci1.pk], lambda x: x.pk) self.assertQuerysetEqual(qs, [ci1.pk], lambda x: x.pk)
def test_ticket15316_one2one_exclude_true(self): def test_ticket15316_one2one_exclude_true(self):
c = SimpleCategory.objects.create(name="cat") c = SimpleCategory.objects.create(name="cat")
c0 = SimpleCategory.objects.create(name="cat0") c0 = SimpleCategory.objects.create(name="cat0")
c1 = SimpleCategory.objects.create(name="category1") c1 = SimpleCategory.objects.create(name="category1")

View File

@ -50,7 +50,7 @@ class UniqueForDateModel(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
class CustomMessagesModel(models.Model): class CustomMessagesModel(models.Model):
other = models.IntegerField(blank=True, null=True) other = models.IntegerField(blank=True, null=True)
number = models.IntegerField(db_column='number_val', number = models.IntegerField(db_column='number_val',
error_messages={'null': 'NULL', 'not42': 'AAARGH', 'not_equal': '%s != me'}, error_messages={'null': 'NULL', 'not42': 'AAARGH', 'not_equal': '%s != me'},
validators=[validate_answer_to_universe] validators=[validate_answer_to_universe]