Start attacking E231 violations

This commit is contained in:
Alex Gaynor 2013-10-24 10:30:03 -07:00
parent 382d324ccc
commit 9bf5610890
31 changed files with 92 additions and 90 deletions

View File

@ -50,7 +50,7 @@ def patterns(prefix, *args):
return pattern_list return pattern_list
def url(regex, view, kwargs=None, name=None, prefix=''): def url(regex, view, kwargs=None, name=None, prefix=''):
if isinstance(view, (list,tuple)): if isinstance(view, (list, tuple)):
# For include(...) processing. # For include(...) processing.
urlconf_module, app_name, namespace = view urlconf_module, app_name, namespace = view
return RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace) return RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace)

View File

@ -26,7 +26,7 @@ register = Library()
DOT = '.' DOT = '.'
@register.simple_tag @register.simple_tag
def paginator_number(cl,i): def paginator_number(cl, i):
""" """
Generates an individual page index link in a paginated list. Generates an individual page index link in a paginated list.
""" """

View File

@ -27,13 +27,13 @@ def auth_processor_no_attr_access(request):
RequestContext(request, {}, processors=[context_processors.auth])) RequestContext(request, {}, processors=[context_processors.auth]))
# *After* rendering, we check whether the session was accessed # *After* rendering, we check whether the session was accessed
return render_to_response('context_processors/auth_attrs_test_access.html', return render_to_response('context_processors/auth_attrs_test_access.html',
{'session_accessed':request.session.accessed}) {'session_accessed': request.session.accessed})
def auth_processor_attr_access(request): def auth_processor_attr_access(request):
render_to_response('context_processors/auth_attrs_access.html', render_to_response('context_processors/auth_attrs_access.html',
RequestContext(request, {}, processors=[context_processors.auth])) RequestContext(request, {}, processors=[context_processors.auth]))
return render_to_response('context_processors/auth_attrs_test_access.html', return render_to_response('context_processors/auth_attrs_test_access.html',
{'session_accessed':request.session.accessed}) {'session_accessed': request.session.accessed})
def auth_processor_user(request): def auth_processor_user(request):
return render_to_response('context_processors/auth_attrs_user.html', return render_to_response('context_processors/auth_attrs_user.html',

View File

@ -45,7 +45,7 @@ class FlatpageCSRFTests(TestCase):
response = self.client.get('/flatpage_root/sekrit/') response = self.client.get('/flatpage_root/sekrit/')
self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/') self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/')
User.objects.create_user('testuser', 'test@example.com', 's3krit') User.objects.create_user('testuser', 'test@example.com', 's3krit')
self.client.login(username='testuser',password='s3krit') self.client.login(username='testuser', password='s3krit')
response = self.client.get('/flatpage_root/sekrit/') response = self.client.get('/flatpage_root/sekrit/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>") self.assertContains(response, "<p>Isn't it sekrit!</p>")

View File

@ -43,7 +43,7 @@ class FlatpageMiddlewareTests(TestCase):
response = self.client.get('/flatpage_root/sekrit/') response = self.client.get('/flatpage_root/sekrit/')
self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/') self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/')
User.objects.create_user('testuser', 'test@example.com', 's3krit') User.objects.create_user('testuser', 'test@example.com', 's3krit')
self.client.login(username='testuser',password='s3krit') self.client.login(username='testuser', password='s3krit')
response = self.client.get('/flatpage_root/sekrit/') response = self.client.get('/flatpage_root/sekrit/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>") self.assertContains(response, "<p>Isn't it sekrit!</p>")
@ -65,7 +65,7 @@ class FlatpageMiddlewareTests(TestCase):
response = self.client.get('/sekrit/') response = self.client.get('/sekrit/')
self.assertRedirects(response, '/accounts/login/?next=/sekrit/') self.assertRedirects(response, '/accounts/login/?next=/sekrit/')
User.objects.create_user('testuser', 'test@example.com', 's3krit') User.objects.create_user('testuser', 'test@example.com', 's3krit')
self.client.login(username='testuser',password='s3krit') self.client.login(username='testuser', password='s3krit')
response = self.client.get('/sekrit/') response = self.client.get('/sekrit/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>") self.assertContains(response, "<p>Isn't it sekrit!</p>")

View File

@ -43,7 +43,7 @@ class FlatpageViewTests(TestCase):
response = self.client.get('/flatpage_root/sekrit/') response = self.client.get('/flatpage_root/sekrit/')
self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/') self.assertRedirects(response, '/accounts/login/?next=/flatpage_root/sekrit/')
User.objects.create_user('testuser', 'test@example.com', 's3krit') User.objects.create_user('testuser', 'test@example.com', 's3krit')
self.client.login(username='testuser',password='s3krit') self.client.login(username='testuser', password='s3krit')
response = self.client.get('/flatpage_root/sekrit/') response = self.client.get('/flatpage_root/sekrit/')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>") self.assertContains(response, "<p>Isn't it sekrit!</p>")

View File

@ -119,7 +119,7 @@ class PreviewTests(TestCase):
``bool1``. We need to make sure the hashes are the same in both cases. ``bool1``. We need to make sure the hashes are the same in both cases.
""" """
self.test_data.update({'stage':2}) self.test_data.update({'stage': 2})
hash = self.preview.security_hash(None, TestForm(self.test_data)) hash = self.preview.security_hash(None, TestForm(self.test_data))
self.test_data.update({'hash': hash, 'bool1': 'False'}) self.test_data.update({'hash': hash, 'bool1': 'False'})
with warnings.catch_warnings(record=True): with warnings.catch_warnings(record=True):
@ -133,7 +133,7 @@ class PreviewTests(TestCase):
""" """
# Pass strings for form submittal and add stage variable to # Pass strings for form submittal and add stage variable to
# show we previously saw first stage of the form. # show we previously saw first stage of the form.
self.test_data.update({'stage':2}) self.test_data.update({'stage': 2})
response = self.client.post('/preview/', self.test_data) response = self.client.post('/preview/', self.test_data)
self.assertNotEqual(response.content, success_string_encoded) self.assertNotEqual(response.content, success_string_encoded)
hash = utils.form_hmac(TestForm(self.test_data)) hash = utils.form_hmac(TestForm(self.test_data))
@ -148,7 +148,7 @@ class PreviewTests(TestCase):
""" """
# Pass strings for form submittal and add stage variable to # Pass strings for form submittal and add stage variable to
# show we previously saw first stage of the form. # show we previously saw first stage of the form.
self.test_data.update({'stage':2}) self.test_data.update({'stage': 2})
response = self.client.post('/preview/', self.test_data) response = self.client.post('/preview/', self.test_data)
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertNotEqual(response.content, success_string_encoded) self.assertNotEqual(response.content, success_string_encoded)

View File

@ -53,7 +53,7 @@ class OpenLayersWidget(Textarea):
self.params['name'] = name self.params['name'] = name
# note: we must switch out dashes for underscores since js # note: we must switch out dashes for underscores since js
# functions are created using the module variable # functions are created using the module variable
js_safe_name = self.params['name'].replace('-','_') js_safe_name = self.params['name'].replace('-', '_')
self.params['module'] = 'geodjango_%s' % js_safe_name self.params['module'] = 'geodjango_%s' % js_safe_name
if value: if value:

View File

@ -286,7 +286,7 @@ class GeoQuerySet(QuerySet):
Reverses the coordinate order of the geometry, and attaches as a Reverses the coordinate order of the geometry, and attaches as a
`reverse` attribute on each element of this GeoQuerySet. `reverse` attribute on each element of this GeoQuerySet.
""" """
s = {'select_field' : GeomField(),} s = {'select_field': GeomField()}
kwargs.setdefault('model_att', 'reverse_geom') kwargs.setdefault('model_att', 'reverse_geom')
if connections[self.db].ops.oracle: if connections[self.db].ops.oracle:
s['geo_field_type'] = LineStringField s['geo_field_type'] = LineStringField
@ -733,7 +733,7 @@ class GeoQuerySet(QuerySet):
DRY routine for setting up a GeoQuerySet method that attaches a DRY routine for setting up a GeoQuerySet method that attaches a
Geometry attribute (e.g., `centroid`, `point_on_surface`). Geometry attribute (e.g., `centroid`, `point_on_surface`).
""" """
s = {'select_field' : GeomField(),} s = {'select_field': GeomField()}
if connections[self.db].ops.oracle: if connections[self.db].ops.oracle:
s['procedure_fmt'] = '%(geo_col)s,%(tolerance)s' s['procedure_fmt'] = '%(geo_col)s,%(tolerance)s'
s['procedure_args'] = {'tolerance' : tolerance} s['procedure_args'] = {'tolerance' : tolerance}

View File

@ -68,7 +68,7 @@ class BaseGeometryWidget(Widget):
context = self.build_attrs(attrs, context = self.build_attrs(attrs,
name=name, name=name,
module='geodjango_%s' % name.replace('-','_'), # JS-safe module='geodjango_%s' % name.replace('-', '_'), # JS-safe
serialized=self.serialize(value), serialized=self.serialize(value),
geom_type=gdal.OGRGeomType(self.attrs['geom_type']), geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
STATIC_URL=settings.STATIC_URL, STATIC_URL=settings.STATIC_URL,

View File

@ -12,20 +12,20 @@ if HAS_GDAL:
# List of acceptable data sources. # List of acceptable data sources.
ds_list = ( ds_list = (
TestDS('test_point', nfeat=5, nfld=3, geom='POINT', gtype=1, driver='ESRI Shapefile', TestDS('test_point', nfeat=5, nfld=3, geom='POINT', gtype=1, driver='ESRI Shapefile',
fields={'dbl' : OFTReal, 'int' : OFTInteger, 'str' : OFTString,}, fields={'dbl': OFTReal, 'int': OFTInteger, 'str': OFTString},
extent=(-1.35011,0.166623,-0.524093,0.824508), # Got extent from QGIS extent=(-1.35011, 0.166623, -0.524093, 0.824508), # Got extent from QGIS
srs_wkt='GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]', srs_wkt='GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]',
field_values={'dbl' : [float(i) for i in range(1, 6)], 'int' : list(range(1, 6)), 'str' : [str(i) for i in range(1, 6)]}, field_values={'dbl': [float(i) for i in range(1, 6)], 'int': list(range(1, 6)), 'str': [str(i) for i in range(1, 6)]},
fids=range(5)), fids=range(5)),
TestDS('test_vrt', ext='vrt', nfeat=3, nfld=3, geom='POINT', gtype='Point25D', driver='VRT', TestDS('test_vrt', ext='vrt', nfeat=3, nfld=3, geom='POINT', gtype='Point25D', driver='VRT',
fields={'POINT_X' : OFTString, 'POINT_Y' : OFTString, 'NUM' : OFTString}, # VRT uses CSV, which all types are OFTString. fields={'POINT_X': OFTString, 'POINT_Y': OFTString, 'NUM': OFTString}, # VRT uses CSV, which all types are OFTString.
extent=(1.0, 2.0, 100.0, 523.5), # Min/Max from CSV extent=(1.0, 2.0, 100.0, 523.5), # Min/Max from CSV
field_values={'POINT_X' : ['1.0', '5.0', '100.0'], 'POINT_Y' : ['2.0', '23.0', '523.5'], 'NUM' : ['5', '17', '23']}, field_values={'POINT_X': ['1.0', '5.0', '100.0'], 'POINT_Y': ['2.0', '23.0', '523.5'], 'NUM': ['5', '17', '23']},
fids=range(1,4)), fids=range(1, 4)),
TestDS('test_poly', nfeat=3, nfld=3, geom='POLYGON', gtype=3, TestDS('test_poly', nfeat=3, nfld=3, geom='POLYGON', gtype=3,
driver='ESRI Shapefile', driver='ESRI Shapefile',
fields={'float' : OFTReal, 'int' : OFTInteger, 'str' : OFTString,}, fields={'float': OFTReal, 'int': OFTInteger, 'str': OFTString},
extent=(-1.01513,-0.558245,0.161876,0.839637), # Got extent from QGIS extent=(-1.01513, -0.558245, 0.161876, 0.839637), # Got extent from QGIS
srs_wkt='GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'), srs_wkt='GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'),
) )

View File

@ -18,20 +18,20 @@ srlist = (TestSRS('GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,29
proj='+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ', proj='+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ',
epsg=4326, projected=False, geographic=True, local=False, epsg=4326, projected=False, geographic=True, local=False,
lin_name='unknown', ang_name='degree', lin_units=1.0, ang_units=0.0174532925199, lin_name='unknown', ang_name='degree', lin_units=1.0, ang_units=0.0174532925199,
auth={'GEOGCS' : ('EPSG', '4326'), 'spheroid' : ('EPSG', '7030')}, auth={'GEOGCS': ('EPSG', '4326'), 'spheroid': ('EPSG', '7030')},
attr=(('DATUM', 'WGS_1984'), (('SPHEROID', 1), '6378137'),('primem|authority', 'EPSG'),), attr=(('DATUM', 'WGS_1984'), (('SPHEROID', 1), '6378137'), ('primem|authority', 'EPSG'),),
), ),
TestSRS('PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",30.28333333333333],PARAMETER["standard_parallel_2",28.38333333333333],PARAMETER["latitude_of_origin",27.83333333333333],PARAMETER["central_meridian",-99],PARAMETER["false_easting",600000],PARAMETER["false_northing",4000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32140"]]', TestSRS('PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",30.28333333333333],PARAMETER["standard_parallel_2",28.38333333333333],PARAMETER["latitude_of_origin",27.83333333333333],PARAMETER["central_meridian",-99],PARAMETER["false_easting",600000],PARAMETER["false_northing",4000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32140"]]',
proj=None, epsg=32140, projected=True, geographic=False, local=False, proj=None, epsg=32140, projected=True, geographic=False, local=False,
lin_name='metre', ang_name='degree', lin_units=1.0, ang_units=0.0174532925199, lin_name='metre', ang_name='degree', lin_units=1.0, ang_units=0.0174532925199,
auth={'PROJCS' : ('EPSG', '32140'), 'spheroid' : ('EPSG', '7019'), 'unit' : ('EPSG', '9001'),}, auth={'PROJCS': ('EPSG', '32140'), 'spheroid': ('EPSG', '7019'), 'unit': ('EPSG', '9001')},
attr=(('DATUM', 'North_American_Datum_1983'),(('SPHEROID', 2), '298.257222101'),('PROJECTION','Lambert_Conformal_Conic_2SP'),), attr=(('DATUM', 'North_American_Datum_1983'), (('SPHEROID', 2), '298.257222101'), ('PROJECTION', 'Lambert_Conformal_Conic_2SP'),),
), ),
TestSRS('PROJCS["NAD_1983_StatePlane_Texas_South_Central_FIPS_4204_Feet",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["False_Easting",1968500.0],PARAMETER["False_Northing",13123333.33333333],PARAMETER["Central_Meridian",-99.0],PARAMETER["Standard_Parallel_1",28.38333333333333],PARAMETER["Standard_Parallel_2",30.28333333333334],PARAMETER["Latitude_Of_Origin",27.83333333333333],UNIT["Foot_US",0.3048006096012192]]', TestSRS('PROJCS["NAD_1983_StatePlane_Texas_South_Central_FIPS_4204_Feet",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["False_Easting",1968500.0],PARAMETER["False_Northing",13123333.33333333],PARAMETER["Central_Meridian",-99.0],PARAMETER["Standard_Parallel_1",28.38333333333333],PARAMETER["Standard_Parallel_2",30.28333333333334],PARAMETER["Latitude_Of_Origin",27.83333333333333],UNIT["Foot_US",0.3048006096012192]]',
proj=None, epsg=None, projected=True, geographic=False, local=False, proj=None, epsg=None, projected=True, geographic=False, local=False,
lin_name='Foot_US', ang_name='Degree', lin_units=0.3048006096012192, ang_units=0.0174532925199, lin_name='Foot_US', ang_name='Degree', lin_units=0.3048006096012192, ang_units=0.0174532925199,
auth={'PROJCS' : (None, None),}, auth={'PROJCS': (None, None)},
attr=(('PROJCS|GeOgCs|spheroid', 'GRS_1980'),(('projcs', 9), 'UNIT'), (('projcs', 11), None),), attr=(('PROJCS|GeOgCs|spheroid', 'GRS_1980'), (('projcs', 9), 'UNIT'), (('projcs', 11), None),),
), ),
# This is really ESRI format, not WKT -- but the import should work the same # This is really ESRI format, not WKT -- but the import should work the same
TestSRS('LOCAL_CS["Non-Earth (Meter)",LOCAL_DATUM["Local Datum",0],UNIT["Meter",1.0],AXIS["X",EAST],AXIS["Y",NORTH]]', TestSRS('LOCAL_CS["Non-Earth (Meter)",LOCAL_DATUM["Local Datum",0],UNIT["Meter",1.0],AXIS["X",EAST],AXIS["Y",NORTH]]',
@ -46,7 +46,7 @@ well_known = (TestSRS('GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",637813
TestSRS('GEOGCS["WGS 72",DATUM["WGS_1972",SPHEROID["WGS 72",6378135,298.26,AUTHORITY["EPSG","7043"]],AUTHORITY["EPSG","6322"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4322"]]', wk='WGS72', name='WGS 72', attrs=(('GEOGCS|AUTHORITY', 1, '4322'), ('SPHEROID', 'WGS 72'))), TestSRS('GEOGCS["WGS 72",DATUM["WGS_1972",SPHEROID["WGS 72",6378135,298.26,AUTHORITY["EPSG","7043"]],AUTHORITY["EPSG","6322"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4322"]]', wk='WGS72', name='WGS 72', attrs=(('GEOGCS|AUTHORITY', 1, '4322'), ('SPHEROID', 'WGS 72'))),
TestSRS('GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.9786982138982,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]]', wk='NAD27', name='NAD27', attrs=(('GEOGCS|AUTHORITY', 1, '4267'), ('SPHEROID', 'Clarke 1866'))), TestSRS('GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.9786982138982,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]]', wk='NAD27', name='NAD27', attrs=(('GEOGCS|AUTHORITY', 1, '4267'), ('SPHEROID', 'Clarke 1866'))),
TestSRS('GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]]', wk='NAD83', name='NAD83', attrs=(('GEOGCS|AUTHORITY', 1, '4269'), ('SPHEROID', 'GRS 1980'))), TestSRS('GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]]', wk='NAD83', name='NAD83', attrs=(('GEOGCS|AUTHORITY', 1, '4269'), ('SPHEROID', 'GRS 1980'))),
TestSRS('PROJCS["NZGD49 / Karamea Circuit",GEOGCS["NZGD49",DATUM["New_Zealand_Geodetic_Datum_1949",SPHEROID["International 1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993],AUTHORITY["EPSG","6272"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4272"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",-41.28991152777778],PARAMETER["central_meridian",172.1090281944444],PARAMETER["scale_factor",1],PARAMETER["false_easting",300000],PARAMETER["false_northing",700000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","27216"]]', wk='EPSG:27216', name='NZGD49 / Karamea Circuit', attrs=(('PROJECTION','Transverse_Mercator'), ('SPHEROID', 'International 1924'))), TestSRS('PROJCS["NZGD49 / Karamea Circuit",GEOGCS["NZGD49",DATUM["New_Zealand_Geodetic_Datum_1949",SPHEROID["International 1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993],AUTHORITY["EPSG","6272"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4272"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",-41.28991152777778],PARAMETER["central_meridian",172.1090281944444],PARAMETER["scale_factor",1],PARAMETER["false_easting",300000],PARAMETER["false_northing",700000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","27216"]]', wk='EPSG:27216', name='NZGD49 / Karamea Circuit', attrs=(('PROJECTION', 'Transverse_Mercator'), ('SPHEROID', 'International 1924'))),
) )
bad_srlist = ('Foobar', 'OOJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",30.28333333333333],PARAMETER["standard_parallel_2",28.38333333333333],PARAMETER["latitude_of_origin",27.83333333333333],PARAMETER["central_meridian",-99],PARAMETER["false_easting",600000],PARAMETER["false_northing",4000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32140"]]',) bad_srlist = ('Foobar', 'OOJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",30.28333333333333],PARAMETER["standard_parallel_2",28.38333333333333],PARAMETER["latitude_of_origin",27.83333333333333],PARAMETER["central_meridian",-99],PARAMETER["false_easting",600000],PARAMETER["false_northing",4000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32140"]]',)

View File

@ -223,7 +223,7 @@ class ListMixin(object):
def sort(self, cmp=None, key=None, reverse=False): def sort(self, cmp=None, key=None, reverse=False):
"Standard list sort method" "Standard list sort method"
if key: if key:
temp = [(key(v),v) for v in self] temp = [(key(v), v) for v in self]
temp.sort(key=lambda x: x[0], reverse=reverse) temp.sort(key=lambda x: x[0], reverse=reverse)
self[:] = [v[1] for v in temp] self[:] = [v[1] for v in temp]
else: else:

View File

@ -757,17 +757,17 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
"Testing three-dimensional geometries." "Testing three-dimensional geometries."
# Testing a 3D Point # Testing a 3D Point
pnt = Point(2, 3, 8) pnt = Point(2, 3, 8)
self.assertEqual((2.,3.,8.), pnt.coords) self.assertEqual((2., 3., 8.), pnt.coords)
self.assertRaises(TypeError, pnt.set_coords, (1.,2.)) self.assertRaises(TypeError, pnt.set_coords, (1., 2.))
pnt.coords = (1.,2.,3.) pnt.coords = (1., 2., 3.)
self.assertEqual((1.,2.,3.), pnt.coords) self.assertEqual((1., 2., 3.), pnt.coords)
# Testing a 3D LineString # Testing a 3D LineString
ls = LineString((2., 3., 8.), (50., 250., -117.)) ls = LineString((2., 3., 8.), (50., 250., -117.))
self.assertEqual(((2.,3.,8.), (50.,250.,-117.)), ls.tuple) self.assertEqual(((2., 3., 8.), (50., 250., -117.)), ls.tuple)
self.assertRaises(TypeError, ls.__setitem__, 0, (1.,2.)) self.assertRaises(TypeError, ls.__setitem__, 0, (1., 2.))
ls[0] = (1.,2.,3.) ls[0] = (1., 2., 3.)
self.assertEqual((1.,2.,3.), ls[0]) self.assertEqual((1., 2., 3.), ls[0])
def test_distance(self): def test_distance(self):
"Testing the distance() function." "Testing the distance() function."

View File

@ -14,7 +14,7 @@ if HAS_GEOS:
if HAS_GEOS: if HAS_GEOS:
def api_get_distance(x): def api_get_distance(x):
return x.distance(Point(-200,-200)) return x.distance(Point(-200, -200))
def api_get_buffer(x): def api_get_buffer(x):
return x.buffer(10) return x.buffer(10)
@ -69,24 +69,24 @@ class GEOSMutationTest(unittest.TestCase):
def test00_GEOSIndexException(self): def test00_GEOSIndexException(self):
'Testing Geometry GEOSIndexError' 'Testing Geometry GEOSIndexError'
p = Point(1,2) p = Point(1, 2)
for i in range(-2,2): for i in range(-2, 2):
p._checkindex(i) p._checkindex(i)
self.assertRaises(GEOSIndexError, p._checkindex, 2) self.assertRaises(GEOSIndexError, p._checkindex, 2)
self.assertRaises(GEOSIndexError, p._checkindex, -3) self.assertRaises(GEOSIndexError, p._checkindex, -3)
def test01_PointMutations(self): def test01_PointMutations(self):
'Testing Point mutations' 'Testing Point mutations'
for p in (Point(1,2,3), fromstr('POINT (1 2 3)')): for p in (Point(1, 2, 3), fromstr('POINT (1 2 3)')):
self.assertEqual(p._get_single_external(1), 2.0, 'Point _get_single_external') self.assertEqual(p._get_single_external(1), 2.0, 'Point _get_single_external')
# _set_single # _set_single
p._set_single(0,100) p._set_single(0, 100)
self.assertEqual(p.coords, (100.0,2.0,3.0), 'Point _set_single') self.assertEqual(p.coords, (100.0, 2.0, 3.0), 'Point _set_single')
# _set_list # _set_list
p._set_list(2,(50,3141)) p._set_list(2, (50, 3141))
self.assertEqual(p.coords, (50.0,3141.0), 'Point _set_list') self.assertEqual(p.coords, (50.0, 3141.0), 'Point _set_list')
def test02_PointExceptions(self): def test02_PointExceptions(self):
'Testing Point exceptions' 'Testing Point exceptions'
@ -95,25 +95,25 @@ class GEOSMutationTest(unittest.TestCase):
def test03_PointApi(self): def test03_PointApi(self):
'Testing Point API' 'Testing Point API'
q = Point(4,5,3) q = Point(4, 5, 3)
for p in (Point(1,2,3), fromstr('POINT (1 2 3)')): for p in (Point(1, 2, 3), fromstr('POINT (1 2 3)')):
p[0:2] = [4,5] p[0:2] = [4, 5]
for f in geos_function_tests: for f in geos_function_tests:
self.assertEqual(f(q), f(p), 'Point ' + f.__name__) self.assertEqual(f(q), f(p), 'Point ' + f.__name__)
def test04_LineStringMutations(self): def test04_LineStringMutations(self):
'Testing LineString mutations' 'Testing LineString mutations'
for ls in (LineString((1,0),(4,1),(6,-1)), for ls in (LineString((1, 0), (4, 1), (6, -1)),
fromstr('LINESTRING (1 0,4 1,6 -1)')): fromstr('LINESTRING (1 0,4 1,6 -1)')):
self.assertEqual(ls._get_single_external(1), (4.0,1.0), 'LineString _get_single_external') self.assertEqual(ls._get_single_external(1), (4.0, 1.0), 'LineString _get_single_external')
# _set_single # _set_single
ls._set_single(0,(-50,25)) ls._set_single(0, (-50, 25))
self.assertEqual(ls.coords, ((-50.0,25.0),(4.0,1.0),(6.0,-1.0)), 'LineString _set_single') self.assertEqual(ls.coords, ((-50.0, 25.0),(4.0, 1.0),(6.0, -1.0)), 'LineString _set_single')
# _set_list # _set_list
ls._set_list(2, ((-50.0,25.0),(6.0,-1.0))) ls._set_list(2, ((-50.0, 25.0), (6.0, -1.0)))
self.assertEqual(ls.coords, ((-50.0,25.0),(6.0,-1.0)), 'LineString _set_list') self.assertEqual(ls.coords, ((-50.0, 25.0), (6.0, -1.0)), 'LineString _set_list')
lsa = LineString(ls.coords) lsa = LineString(ls.coords)
for f in geos_function_tests: for f in geos_function_tests:

View File

@ -320,7 +320,7 @@ class ListMixinTest(unittest.TestCase):
def setfcn(x, i, v): def setfcn(x, i, v):
x[i] = v x[i] = v
self.assertRaises(TypeError, setfcn, ul, slice(0,3,2), 2) self.assertRaises(TypeError, setfcn, ul, slice(0, 3, 2), 2)
def test10_checkindex(self): def test10_checkindex(self):
'Index check' 'Index check'
@ -374,7 +374,7 @@ class ListMixinTest(unittest.TestCase):
self.assertEqual(pl[:], ul[:], 'in-place add') self.assertEqual(pl[:], ul[:], 'in-place add')
self.assertEqual(objid, id(ul), 'in-place add id') self.assertEqual(objid, id(ul), 'in-place add id')
for n in (-1,0,1,3): for n in (-1, 0, 1, 3):
pl, ul = self.lists_of_len() pl, ul = self.lists_of_len()
self.assertEqual(list(pl * n), list(ul * n), 'mul by %d' % n) self.assertEqual(list(pl * n), list(ul * n), 'mul by %d' % n)
self.assertEqual(type(ul), type(ul * n), 'type of mul by %d result' % n) self.assertEqual(type(ul), type(ul * n), 'type of mul by %d result' % n)

View File

@ -103,42 +103,42 @@ class MeasureBase(object):
return self.__class__(default_unit=self._default_unit, return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard + other.standard)}) **{self.STANDARD_UNIT: (self.standard + other.standard)})
else: else:
raise TypeError('%(class)s must be added with %(class)s' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be added with %(class)s' % {"class": pretty_name(self)})
def __iadd__(self, other): def __iadd__(self, other):
if isinstance(other, self.__class__): if isinstance(other, self.__class__):
self.standard += other.standard self.standard += other.standard
return self return self
else: else:
raise TypeError('%(class)s must be added with %(class)s' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be added with %(class)s' % {"class": pretty_name(self)})
def __sub__(self, other): def __sub__(self, other):
if isinstance(other, self.__class__): if isinstance(other, self.__class__):
return self.__class__(default_unit=self._default_unit, return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard - other.standard)}) **{self.STANDARD_UNIT: (self.standard - other.standard)})
else: else:
raise TypeError('%(class)s must be subtracted from %(class)s' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be subtracted from %(class)s' % {"class": pretty_name(self)})
def __isub__(self, other): def __isub__(self, other):
if isinstance(other, self.__class__): if isinstance(other, self.__class__):
self.standard -= other.standard self.standard -= other.standard
return self return self
else: else:
raise TypeError('%(class)s must be subtracted from %(class)s' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be subtracted from %(class)s' % {"class": pretty_name(self)})
def __mul__(self, other): def __mul__(self, other):
if isinstance(other, NUMERIC_TYPES): if isinstance(other, NUMERIC_TYPES):
return self.__class__(default_unit=self._default_unit, return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard * other)}) **{self.STANDARD_UNIT: (self.standard * other)})
else: else:
raise TypeError('%(class)s must be multiplied with number' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be multiplied with number' % {"class": pretty_name(self)})
def __imul__(self, other): def __imul__(self, other):
if isinstance(other, NUMERIC_TYPES): if isinstance(other, NUMERIC_TYPES):
self.standard *= float(other) self.standard *= float(other)
return self return self
else: else:
raise TypeError('%(class)s must be multiplied with number' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be multiplied with number' % {"class": pretty_name(self)})
def __rmul__(self, other): def __rmul__(self, other):
return self * other return self * other
@ -150,7 +150,7 @@ class MeasureBase(object):
return self.__class__(default_unit=self._default_unit, return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard / other)}) **{self.STANDARD_UNIT: (self.standard / other)})
else: else:
raise TypeError('%(class)s must be divided with number or %(class)s' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be divided with number or %(class)s' % {"class": pretty_name(self)})
def __div__(self, other): # Python 2 compatibility def __div__(self, other): # Python 2 compatibility
return type(self).__truediv__(self, other) return type(self).__truediv__(self, other)
@ -160,7 +160,7 @@ class MeasureBase(object):
self.standard /= float(other) self.standard /= float(other)
return self return self
else: else:
raise TypeError('%(class)s must be divided with number' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be divided with number' % {"class": pretty_name(self)})
def __idiv__(self, other): # Python 2 compatibility def __idiv__(self, other): # Python 2 compatibility
return type(self).__itruediv__(self, other) return type(self).__itruediv__(self, other)
@ -304,7 +304,7 @@ class Distance(MeasureBase):
**{self.STANDARD_UNIT: (self.standard * other)}) **{self.STANDARD_UNIT: (self.standard * other)})
else: else:
raise TypeError('%(distance)s must be multiplied with number or %(distance)s' % { raise TypeError('%(distance)s must be multiplied with number or %(distance)s' % {
"distance" : pretty_name(self.__class__), "distance": pretty_name(self.__class__),
}) })
@ -320,7 +320,7 @@ class Area(MeasureBase):
return self.__class__(default_unit=self._default_unit, return self.__class__(default_unit=self._default_unit,
**{self.STANDARD_UNIT: (self.standard / other)}) **{self.STANDARD_UNIT: (self.standard / other)})
else: else:
raise TypeError('%(class)s must be divided by a number' % {"class":pretty_name(self)}) raise TypeError('%(class)s must be divided by a number' % {"class": pretty_name(self)})
def __div__(self, other): # Python 2 compatibility def __div__(self, other): # Python 2 compatibility
return type(self).__truediv__(self, other) return type(self).__truediv__(self, other)

View File

@ -32,7 +32,7 @@ def ping_google(sitemap_url=None, ping_url=PING_URL):
current_site = Site.objects.get_current() current_site = Site.objects.get_current()
url = "http://%s%s" % (current_site.domain, sitemap_url) url = "http://%s%s" % (current_site.domain, sitemap_url)
params = urlencode({'sitemap':url}) params = urlencode({'sitemap': url})
urlopen("%s?%s" % (ping_url, params)) urlopen("%s?%s" % (ping_url, params))
class Sitemap(object): class Sitemap(object):

View File

@ -141,7 +141,7 @@ class FileBasedCache(BaseCache):
def _get_num_entries(self): def _get_num_entries(self):
count = 0 count = 0
for _,_,files in os.walk(self._dir): for _, _, files in os.walk(self._dir):
count += len(files) count += len(files)
return count return count
_num_entries = property(_get_num_entries) _num_entries = property(_get_num_entries)

View File

@ -14,7 +14,7 @@ Example Usage::
... f.write('Django') ... f.write('Django')
""" """
__all__ = ('LOCK_EX','LOCK_SH','LOCK_NB','lock','unlock') __all__ = ('LOCK_EX', 'LOCK_SH', 'LOCK_NB', 'lock', 'unlock')
system_type = None system_type = None

View File

@ -26,7 +26,7 @@ __all__ = ['file_move_safe']
def _samefile(src, dst): def _samefile(src, dst):
# Macintosh, Unix. # Macintosh, Unix.
if hasattr(os.path,'samefile'): if hasattr(os.path, 'samefile'):
try: try:
return os.path.samefile(src, dst) return os.path.samefile(src, dst)
except OSError: except OSError:

View File

@ -11,9 +11,11 @@ from django.core.files.uploadedfile import TemporaryUploadedFile, InMemoryUpload
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
from django.utils.module_loading import import_by_path from django.utils.module_loading import import_by_path
__all__ = ['UploadFileException','StopUpload', 'SkipFile', 'FileUploadHandler', __all__ = [
'TemporaryFileUploadHandler', 'MemoryFileUploadHandler', 'UploadFileException', 'StopUpload', 'SkipFile', 'FileUploadHandler',
'load_handler', 'StopFutureHandlers'] 'TemporaryFileUploadHandler', 'MemoryFileUploadHandler', 'load_handler',
'StopFutureHandlers'
]
class UploadFileException(Exception): class UploadFileException(Exception):
""" """

View File

@ -14,7 +14,7 @@ class EmailBackend(ConsoleEmailBackend):
if 'file_path' in kwargs: if 'file_path' in kwargs:
self.file_path = kwargs.pop('file_path') self.file_path = kwargs.pop('file_path')
else: else:
self.file_path = getattr(settings, 'EMAIL_FILE_PATH',None) self.file_path = getattr(settings, 'EMAIL_FILE_PATH', None)
# Make sure self.file_path is a string. # Make sure self.file_path is a string.
if not isinstance(self.file_path, six.string_types): if not isinstance(self.file_path, six.string_types):
raise ImproperlyConfigured('Path for saving emails is invalid: %r' % self.file_path) raise ImproperlyConfigured('Path for saving emails is invalid: %r' % self.file_path)

View File

@ -70,7 +70,7 @@ class BoundMethodWeakref(object):
_allInstances = weakref.WeakValueDictionary() _allInstances = weakref.WeakValueDictionary()
def __new__(cls, target, onDelete=None, *arguments,**named): def __new__(cls, target, onDelete=None, *arguments, **named):
"""Create new instance or return current instance """Create new instance or return current instance
Basically this method of construction allows us to Basically this method of construction allows us to

View File

@ -859,7 +859,7 @@ class BaseInlineFormSet(BaseModelFormSet):
@classmethod @classmethod
def get_default_prefix(cls): def get_default_prefix(cls):
from django.db.models.fields.related import RelatedObject from django.db.models.fields.related import RelatedObject
return RelatedObject(cls.fk.rel.to, cls.model, cls.fk).get_accessor_name().replace('+','') return RelatedObject(cls.fk.rel.to, cls.model, cls.fk).get_accessor_name().replace('+', '')
def save_new(self, form, commit=True): def save_new(self, form, commit=True):
# Use commit=False so we can assign the parent key afterwards, then # Use commit=False so we can assign the parent key afterwards, then

View File

@ -660,7 +660,7 @@ class ChoiceFieldRenderer(object):
output = [start_tag] output = [start_tag]
for i, choice in enumerate(self.choices): for i, choice in enumerate(self.choices):
choice_value, choice_label = choice choice_value, choice_label = choice
if isinstance(choice_label, (tuple,list)): if isinstance(choice_label, (tuple, list)):
attrs_plus = self.attrs.copy() attrs_plus = self.attrs.copy()
if id_: if id_:
attrs_plus['id'] += '_{0}'.format(i) attrs_plus['id'] += '_{0}'.format(i)

View File

@ -810,7 +810,7 @@ def filesizeformat(bytes):
""" """
try: try:
bytes = float(bytes) bytes = float(bytes)
except (TypeError,ValueError,UnicodeDecodeError): except (TypeError, ValueError, UnicodeDecodeError):
value = ungettext("%(size)d byte", "%(size)d bytes", 0) % {'size': 0} value = ungettext("%(size)d byte", "%(size)d bytes", 0) % {'size': 0}
return avoid_wrapping(value) return avoid_wrapping(value)

View File

@ -723,7 +723,7 @@ class EmptyModelVisibleAdmin(admin.ModelAdmin):
form = FormWithoutHiddenField form = FormWithoutHiddenField
fieldsets = ( fieldsets = (
(None, { (None, {
'fields':(('first', 'second'),), 'fields': (('first', 'second'),),
}), }),
) )

View File

@ -340,7 +340,7 @@ class BaseAggregateTestCase(TestCase):
price=Decimal("1000"), price=Decimal("1000"),
publisher=p, publisher=p,
contact_id=1, contact_id=1,
pubdate=datetime.date(2008,12,1) pubdate=datetime.date(2008, 12, 1)
) )
Book.objects.create( Book.objects.create(
name='ExpensiveBook2', name='ExpensiveBook2',
@ -350,7 +350,7 @@ class BaseAggregateTestCase(TestCase):
price=Decimal("1000"), price=Decimal("1000"),
publisher=p, publisher=p,
contact_id=1, contact_id=1,
pubdate=datetime.date(2008,12,2) pubdate=datetime.date(2008, 12, 2)
) )
Book.objects.create( Book.objects.create(
name='ExpensiveBook3', name='ExpensiveBook3',
@ -360,7 +360,7 @@ class BaseAggregateTestCase(TestCase):
price=Decimal("35"), price=Decimal("35"),
publisher=p, publisher=p,
contact_id=1, contact_id=1,
pubdate=datetime.date(2008,12,3) pubdate=datetime.date(2008, 12, 3)
) )
publishers = Publisher.objects.annotate(num_books=Count("book__id")).filter(num_books__gt=1).order_by("pk") publishers = Publisher.objects.annotate(num_books=Count("book__id")).filter(num_books__gt=1).order_by("pk")

View File

@ -35,7 +35,7 @@ class InspectDBTestCase(TestCase):
"""Test introspection of various Django field types""" """Test introspection of various Django field types"""
out = StringIO() out = StringIO()
call_command('inspectdb', call_command('inspectdb',
table_name_filter=lambda tn:tn.startswith('inspectdb_columntypes'), table_name_filter=lambda tn: tn.startswith('inspectdb_columntypes'),
stdout=out) stdout=out)
output = out.getvalue() output = out.getvalue()

View File

@ -129,9 +129,9 @@ class GenericIPAddressFieldTests(ValidationTestCase):
def test_invalid_v4_ip_raises_error(self): def test_invalid_v4_ip_raises_error(self):
giptm = GenericIPAddressTestModel(v4_ip="294.4.2.1") giptm = GenericIPAddressTestModel(v4_ip="294.4.2.1")
self.assertFailsValidation(giptm.full_clean, ['v4_ip',]) self.assertFailsValidation(giptm.full_clean, ['v4_ip'])
giptm = GenericIPAddressTestModel(v4_ip="2001::2") giptm = GenericIPAddressTestModel(v4_ip="2001::2")
self.assertFailsValidation(giptm.full_clean, ['v4_ip',]) self.assertFailsValidation(giptm.full_clean, ['v4_ip'])
def test_correct_v6_ip_passes(self): def test_correct_v6_ip_passes(self):
giptm = GenericIPAddressTestModel(v6_ip="2001::2") giptm = GenericIPAddressTestModel(v6_ip="2001::2")
@ -139,16 +139,16 @@ class GenericIPAddressFieldTests(ValidationTestCase):
def test_invalid_v6_ip_raises_error(self): def test_invalid_v6_ip_raises_error(self):
giptm = GenericIPAddressTestModel(v6_ip="1.2.3.4") giptm = GenericIPAddressTestModel(v6_ip="1.2.3.4")
self.assertFailsValidation(giptm.full_clean, ['v6_ip',]) self.assertFailsValidation(giptm.full_clean, ['v6_ip'])
giptm = GenericIPAddressTestModel(v6_ip="1:2") giptm = GenericIPAddressTestModel(v6_ip="1:2")
self.assertFailsValidation(giptm.full_clean, ['v6_ip',]) self.assertFailsValidation(giptm.full_clean, ['v6_ip'])
def test_v6_uniqueness_detection(self): def test_v6_uniqueness_detection(self):
# These two addresses are the same with different syntax # These two addresses are the same with different syntax
giptm = GenericIPAddressTestModel(generic_ip="2001::1:0:0:0:0:2") giptm = GenericIPAddressTestModel(generic_ip="2001::1:0:0:0:0:2")
giptm.save() giptm.save()
giptm = GenericIPAddressTestModel(generic_ip="2001:0:1:2") giptm = GenericIPAddressTestModel(generic_ip="2001:0:1:2")
self.assertFailsValidation(giptm.full_clean, ['generic_ip',]) self.assertFailsValidation(giptm.full_clean, ['generic_ip'])
def test_v4_unpack_uniqueness_detection(self): def test_v4_unpack_uniqueness_detection(self):
# These two are different, because we are not doing IPv4 unpacking # These two are different, because we are not doing IPv4 unpacking