mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Removed a ton of unused local vars
This commit is contained in:
@@ -23,14 +23,14 @@ def remote_user_auth_view(request):
|
||||
return HttpResponse(t.render(c))
|
||||
|
||||
def auth_processor_no_attr_access(request):
|
||||
r1 = render_to_response('context_processors/auth_attrs_no_access.html',
|
||||
render_to_response('context_processors/auth_attrs_no_access.html',
|
||||
RequestContext(request, {}, processors=[context_processors.auth]))
|
||||
# *After* rendering, we check whether the session was accessed
|
||||
return render_to_response('context_processors/auth_attrs_test_access.html',
|
||||
{'session_accessed':request.session.accessed})
|
||||
|
||||
def auth_processor_attr_access(request):
|
||||
r1 = render_to_response('context_processors/auth_attrs_access.html',
|
||||
render_to_response('context_processors/auth_attrs_access.html',
|
||||
RequestContext(request, {}, processors=[context_processors.auth]))
|
||||
return render_to_response('context_processors/auth_attrs_test_access.html',
|
||||
{'session_accessed':request.session.accessed})
|
||||
|
||||
@@ -74,7 +74,6 @@ class SpatiaLiteCreation(DatabaseCreation):
|
||||
|
||||
if isinstance(f, GeometryField):
|
||||
gqn = self.connection.ops.geo_quote_name
|
||||
qn = self.connection.ops.quote_name
|
||||
db_table = model._meta.db_table
|
||||
|
||||
output.append(style.SQL_KEYWORD('SELECT ') +
|
||||
|
||||
@@ -469,7 +469,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||
|
||||
def test_multipolygons(self):
|
||||
"Testing MultiPolygon objects."
|
||||
prev = fromstr('POINT (0 0)')
|
||||
fromstr('POINT (0 0)')
|
||||
for mp in self.geometries.multipolygons:
|
||||
mpoly = fromstr(mp.wkt)
|
||||
self.assertEqual(mpoly.geom_type, 'MultiPolygon')
|
||||
@@ -709,7 +709,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||
new = Point(random.randint(21, 100), random.randint(21, 100))
|
||||
# Testing the assignment
|
||||
mp[i] = new
|
||||
s = str(new) # what was used for the assignment is still accessible
|
||||
str(new) # what was used for the assignment is still accessible
|
||||
self.assertEqual(mp[i], new)
|
||||
self.assertEqual(mp[i].wkt, new.wkt)
|
||||
self.assertNotEqual(pnt, mp[i])
|
||||
@@ -730,7 +730,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
||||
self.assertNotEqual(mpoly[i], poly)
|
||||
# Testing the assignment
|
||||
mpoly[i] = poly
|
||||
s = str(poly) # Still accessible
|
||||
str(poly) # Still accessible
|
||||
self.assertEqual(mpoly[i], poly)
|
||||
self.assertNotEqual(mpoly[i], old_poly)
|
||||
|
||||
|
||||
@@ -93,8 +93,8 @@ class Command(LabelCommand):
|
||||
show_mapping = options.pop('mapping', False)
|
||||
|
||||
# Getting rid of settings that `_ogrinspect` doesn't like.
|
||||
verbosity = options.pop('verbosity', False)
|
||||
settings = options.pop('settings', False)
|
||||
options.pop('verbosity', False)
|
||||
options.pop('settings', False)
|
||||
|
||||
# Returning the output of ogrinspect with the given arguments
|
||||
# and options.
|
||||
|
||||
@@ -37,7 +37,7 @@ class GeoRegressionTests(TestCase):
|
||||
'description' : name,
|
||||
'kml' : '<Point><coordinates>5.0,23.0</coordinates></Point>'
|
||||
}]
|
||||
kmz = render_to_kmz('gis/kml/placemarks.kml', {'places' : places})
|
||||
render_to_kmz('gis/kml/placemarks.kml', {'places' : places})
|
||||
|
||||
@no_spatialite
|
||||
@no_mysql
|
||||
@@ -52,8 +52,8 @@ class GeoRegressionTests(TestCase):
|
||||
def test_unicode_date(self):
|
||||
"Testing dates are converted properly, even on SpatiaLite. See #16408."
|
||||
founded = datetime(1857, 5, 23)
|
||||
mansfield = PennsylvaniaCity.objects.create(name='Mansfield', county='Tioga', point='POINT(-77.071445 41.823881)',
|
||||
founded=founded)
|
||||
PennsylvaniaCity.objects.create(name='Mansfield', county='Tioga', point='POINT(-77.071445 41.823881)',
|
||||
founded=founded)
|
||||
self.assertEqual(founded, PennsylvaniaCity.objects.datetimes('founded', 'day')[0])
|
||||
self.assertEqual(founded, PennsylvaniaCity.objects.aggregate(Min('founded'))['founded__min'])
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ class GeoModelTest(TestCase):
|
||||
def test_inherited_geofields(self):
|
||||
"Test GeoQuerySet methods on inherited Geometry fields."
|
||||
# Creating a Pennsylvanian city.
|
||||
mansfield = PennsylvaniaCity.objects.create(name='Mansfield', county='Tioga', point='POINT(-77.071445 41.823881)')
|
||||
PennsylvaniaCity.objects.create(name='Mansfield', county='Tioga', point='POINT(-77.071445 41.823881)')
|
||||
|
||||
# All transformation SQL will need to be performed on the
|
||||
# _parent_ table.
|
||||
@@ -410,7 +410,6 @@ class GeoQuerySetTest(TestCase):
|
||||
def test_diff_intersection_union(self):
|
||||
"Testing the `difference`, `intersection`, `sym_difference`, and `union` GeoQuerySet methods."
|
||||
geom = Point(5, 23)
|
||||
tol = 1
|
||||
qs = Country.objects.all().difference(geom).sym_difference(geom).union(geom)
|
||||
|
||||
# XXX For some reason SpatiaLite does something screwey with the Texas geometry here. Also,
|
||||
@@ -692,7 +691,7 @@ class GeoQuerySetTest(TestCase):
|
||||
'12.46472 43.89555,12.45917 43.89611,12.41639 43.90472,'
|
||||
'12.41222 43.90610,12.40782 43.91366,12.40389 43.92667,'
|
||||
'12.40500 43.94833,12.40889 43.95499,12.41580 43.95795)))')
|
||||
sm = Country.objects.create(name='San Marino', mpoly=fromstr(wkt))
|
||||
Country.objects.create(name='San Marino', mpoly=fromstr(wkt))
|
||||
|
||||
# Because floating-point arithmetic isn't exact, we set a tolerance
|
||||
# to pass into GEOS `equals_exact`.
|
||||
|
||||
@@ -42,7 +42,7 @@ class GeographyTest(TestCase):
|
||||
"Testing GeoQuerySet.distance() support on non-point geography fields."
|
||||
# `GeoQuerySet.distance` is not allowed geometry fields.
|
||||
htown = City.objects.get(name='Houston')
|
||||
qs = Zipcode.objects.distance(htown.point)
|
||||
Zipcode.objects.distance(htown.point)
|
||||
|
||||
def test04_invalid_operators_functions(self):
|
||||
"Ensuring exceptions are raised for operators & functions invalid on geography fields."
|
||||
|
||||
@@ -58,11 +58,11 @@ class LayerMapTest(TestCase):
|
||||
# ensuring that a LayerMapError is raised.
|
||||
for bad_map in (bad1, bad2, bad3):
|
||||
with self.assertRaises(LayerMapError):
|
||||
lm = LayerMapping(City, city_shp, bad_map)
|
||||
LayerMapping(City, city_shp, bad_map)
|
||||
|
||||
# A LookupError should be thrown for bogus encodings.
|
||||
with self.assertRaises(LookupError):
|
||||
lm = LayerMapping(City, city_shp, city_mapping, encoding='foobar')
|
||||
LayerMapping(City, city_shp, city_mapping, encoding='foobar')
|
||||
|
||||
def test_simple_layermap(self):
|
||||
"Test LayerMapping import of a simple point shapefile."
|
||||
|
||||
@@ -119,7 +119,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
def test05_select_related_fk_to_subclass(self):
|
||||
"Testing that calling select_related on a query over a model with an FK to a model subclass works"
|
||||
# Regression test for #9752.
|
||||
l = list(DirectoryEntry.objects.all().select_related())
|
||||
list(DirectoryEntry.objects.all().select_related())
|
||||
|
||||
def test06_f_expressions(self):
|
||||
"Testing F() expressions on GeometryFields."
|
||||
@@ -134,7 +134,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
c1 = pcity.location.point
|
||||
c2 = c1.transform(2276, clone=True)
|
||||
b2 = c2.buffer(100)
|
||||
p1 = Parcel.objects.create(name='P1', city=pcity, center1=c1, center2=c2, border1=b1, border2=b2)
|
||||
Parcel.objects.create(name='P1', city=pcity, center1=c1, center2=c2, border1=b1, border2=b2)
|
||||
|
||||
# Now creating a second Parcel where the borders are the same, just
|
||||
# in different coordinate systems. The center points are also the
|
||||
@@ -142,7 +142,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
# actually correspond to the centroid of the border.
|
||||
c1 = b1.centroid
|
||||
c2 = c1.transform(2276, clone=True)
|
||||
p2 = Parcel.objects.create(name='P2', city=pcity, center1=c1, center2=c2, border1=b1, border2=b1)
|
||||
Parcel.objects.create(name='P2', city=pcity, center1=c1, center2=c2, border1=b1, border2=b1)
|
||||
|
||||
# Should return the second Parcel, which has the center within the
|
||||
# border.
|
||||
@@ -263,7 +263,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
@no_oracle
|
||||
def test13_select_related_null_fk(self):
|
||||
"Testing `select_related` on a nullable ForeignKey via `GeoManager`. See #11381."
|
||||
no_author = Book.objects.create(title='Without Author')
|
||||
Book.objects.create(title='Without Author')
|
||||
b = Book.objects.select_related('author').get(title='Without Author')
|
||||
# Should be `None`, and not a 'dummy' model.
|
||||
self.assertEqual(None, b.author)
|
||||
@@ -294,7 +294,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
# This triggers TypeError when `get_default_columns` has no `local_only`
|
||||
# keyword. The TypeError is swallowed if QuerySet is actually
|
||||
# evaluated as list generation swallows TypeError in CPython.
|
||||
sql = str(qs.query)
|
||||
str(qs.query)
|
||||
|
||||
def test16_annotated_date_queryset(self):
|
||||
"Ensure annotated date querysets work if spatial backend is used. See #14648."
|
||||
|
||||
@@ -64,20 +64,16 @@ class DistanceTest(unittest.TestCase):
|
||||
self.assertEqual(d4.m, -200)
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
d5 = d1 + 1
|
||||
self.fail('Distance + number should raise TypeError')
|
||||
d1 + 1
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
d5 = d1 - 1
|
||||
self.fail('Distance - number should raise TypeError')
|
||||
d1 - 1
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
d1 += 1
|
||||
self.fail('Distance += number should raise TypeError')
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
d1 -= 1
|
||||
self.fail('Distance -= number should raise TypeError')
|
||||
|
||||
def testMultiplication(self):
|
||||
"Test multiplication & division"
|
||||
@@ -103,11 +99,9 @@ class DistanceTest(unittest.TestCase):
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
d1 *= D(m=1)
|
||||
self.fail('Distance *= Distance should raise TypeError')
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
d1 /= D(m=1)
|
||||
self.fail('Distance /= Distance should raise TypeError')
|
||||
|
||||
def testUnitConversions(self):
|
||||
"Testing default units during maths"
|
||||
@@ -196,20 +190,16 @@ class AreaTest(unittest.TestCase):
|
||||
self.assertEqual(a4.sq_m, -200)
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a5 = a1 + 1
|
||||
self.fail('Area + number should raise TypeError')
|
||||
a1 + 1
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a5 = a1 - 1
|
||||
self.fail('Area - number should raise TypeError')
|
||||
a1 - 1
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a1 += 1
|
||||
self.fail('Area += number should raise TypeError')
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a1 -= 1
|
||||
self.fail('Area -= number should raise TypeError')
|
||||
|
||||
def testMultiplication(self):
|
||||
"Test multiplication & division"
|
||||
@@ -228,20 +218,16 @@ class AreaTest(unittest.TestCase):
|
||||
self.assertEqual(a4.sq_m, 10)
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a5 = a1 * A(sq_m=1)
|
||||
self.fail('Area * Area should raise TypeError')
|
||||
a1 * A(sq_m=1)
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a1 *= A(sq_m=1)
|
||||
self.fail('Area *= Area should raise TypeError')
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a5 = a1 / A(sq_m=1)
|
||||
self.fail('Area / Area should raise TypeError')
|
||||
a1 / A(sq_m=1)
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a1 /= A(sq_m=1)
|
||||
self.fail('Area /= Area should raise TypeError')
|
||||
|
||||
def testUnitConversions(self):
|
||||
"Testing default units during maths"
|
||||
|
||||
@@ -92,8 +92,6 @@ class SpatialRefSysTest(unittest.TestCase):
|
||||
ellps2 = srs.ellipsoid
|
||||
|
||||
for i in range(3):
|
||||
param1 = ellps1[i]
|
||||
param2 = ellps2[i]
|
||||
self.assertAlmostEqual(ellps1[i], ellps2[i], prec[i])
|
||||
|
||||
def suite():
|
||||
|
||||
@@ -216,7 +216,7 @@ class LayerMapping(object):
|
||||
for rel_name, ogr_field in ogr_name.items():
|
||||
idx = check_ogr_fld(ogr_field)
|
||||
try:
|
||||
rel_field = rel_model._meta.get_field(rel_name)
|
||||
rel_model._meta.get_field(rel_name)
|
||||
except models.fields.FieldDoesNotExist:
|
||||
raise LayerMapError('ForeignKey mapping field "%s" not in %s fields.' %
|
||||
(rel_name, rel_model.__class__.__name__))
|
||||
|
||||
@@ -72,9 +72,9 @@ def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
|
||||
try:
|
||||
# Try getting via SRID only, because using all kwargs may
|
||||
# differ from exact wkt/proj in database.
|
||||
sr = SpatialRefSys.objects.using(database).get(srid=srs.srid)
|
||||
SpatialRefSys.objects.using(database).get(srid=srs.srid)
|
||||
except SpatialRefSys.DoesNotExist:
|
||||
sr = SpatialRefSys.objects.using(database).create(**kwargs)
|
||||
SpatialRefSys.objects.using(database).create(**kwargs)
|
||||
|
||||
# Alias is for backwards-compatibility purposes.
|
||||
add_postgis_srs = add_srs_entry
|
||||
|
||||
@@ -230,7 +230,7 @@ class BaseTests(object):
|
||||
data = {
|
||||
'messages': ['Test message %d' % x for x in range(5)],
|
||||
}
|
||||
show_url = reverse('django.contrib.messages.tests.urls.show')
|
||||
reverse('django.contrib.messages.tests.urls.show')
|
||||
for level in ('debug', 'info', 'success', 'warning', 'error'):
|
||||
add_url = reverse('django.contrib.messages.tests.urls.add',
|
||||
args=(level,))
|
||||
|
||||
Reference in New Issue
Block a user