Permalink
Browse files

Removed a ton of unused local vars

  • Loading branch information...
1 parent 0ee8aa5 commit 96fd5557f93ba3aa89a40f474014308cc44cca0d @alex alex committed Sep 8, 2013
@@ -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 @@ def sql_indexes_for_field(self, model, f, style):
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 @@ def test_polygon_comparison(self):
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 @@ def test_mutable_geometries(self):
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 @@ def test_mutable_geometries(self):
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 @@ def handle(self, *args, **options):
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 @@ def test_kmz(self):
'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 @@ def test_extent(self):
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 @@ def test_geometryfield(self):
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 @@ def test_centroid(self):
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 @@ def test_snap_to_grid(self):
'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 @@ def test03_distance_method(self):
"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 @@ def test_init(self):
# 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 @@ def test04b_related_union_aggregate(self):
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,15 +134,15 @@ def test06_f_expressions(self):
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
# same (but in different coordinate systems), and this time they
# 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 @@ def test13c_count(self):
@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 @@ def test15_invalid_select_related(self):
# 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 @@ def testAddition(self):
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 @@ def testMultiplication(self):
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 @@ def testAddition(self):
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 @@ def testMultiplication(self):
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 @@ def test03_ellipsoid(self):
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 @@ def check_ogr_fld(ogr_map_fld):
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 @@ def test_middleware_disabled(self):
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,))
@@ -160,7 +160,7 @@ def test_result_list_editable(self):
new_parent = Parent.objects.create(name='parent')
for i in range(200):
- new_child = Child.objects.create(name='name %s' % i, parent=new_parent)
+ Child.objects.create(name='name %s' % i, parent=new_parent)
request = self.factory.get('/child/', data={'p': -1}) # Anything outside range
m = ChildAdmin(Child, admin.site)
@@ -176,7 +176,7 @@ def test_result_list_editable(self):
def test_custom_paginator(self):
new_parent = Parent.objects.create(name='parent')
for i in range(200):
- new_child = Child.objects.create(name='name %s' % i, parent=new_parent)
+ Child.objects.create(name='name %s' % i, parent=new_parent)
request = self.factory.get('/child/')
m = CustomPaginationAdmin(Child, admin.site)
@@ -8,11 +8,11 @@
from django.test.utils import override_settings
# local test models
-from .admin import InnerInline, TitleInline, site
+from .admin import InnerInline
from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person,
OutfitItem, Fashionista, Teacher, Parent, Child, Author, Book, Profile,
ProfileCollection, ParentModelWithCustomPk, ChildModel1, ChildModel2,
- Sighting, Title, Novel, Chapter, FootNote, BinaryTree)
+ Sighting, Novel, Chapter, FootNote, BinaryTree)
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
@@ -45,7 +45,7 @@ def test_can_delete(self):
def test_readonly_stacked_inline_label(self):
"""Bug #13174."""
holder = Holder.objects.create(dummy=42)
- inner = Inner.objects.create(holder=holder, dummy=42, readonly='')
+ Inner.objects.create(holder=holder, dummy=42, readonly='')
response = self.client.get('/admin/admin_inlines/holder/%i/'
% holder.id)
self.assertContains(response, '<label>Inner readonly label:</label>')
@@ -195,7 +195,7 @@ def test_create_inlines_on_inherited_model(self):
def test_custom_get_extra_form(self):
bt_head = BinaryTree.objects.create(name="Tree Head")
- bt_child = BinaryTree.objects.create(name="First Child", parent=bt_head)
+ BinaryTree.objects.create(name="First Child", parent=bt_head)
# The maximum number of forms should respect 'get_max_num' on the
# ModelAdmin
@@ -575,7 +575,6 @@ def test_add_inlines(self):
Ensure that the "Add another XXX" link correctly adds items to the
inline form.
"""
- from selenium.common.exceptions import TimeoutException
self.admin_login(username='super', password='secret')
self.selenium.get('%s%s' % (self.live_server_url,
'/admin/admin_inlines/profilecollection/add/'))
@@ -106,7 +106,6 @@ def _ext_backend_paths(self):
return paths
def run_test(self, script, args, settings_file=None, apps=None):
- project_dir = test_dir
base_dir = os.path.dirname(test_dir)
# The base dir for Django's tests is one level up.
tests_dir = os.path.dirname(os.path.dirname(__file__))
Oops, something went wrong.

0 comments on commit 96fd555

Please sign in to comment.