mirror of
https://github.com/django/django.git
synced 2025-06-07 04:29:12 +00:00
Fixed a number of lint warnings, particularly around unused variables.
This commit is contained in:
parent
ebb3e50243
commit
3e0eb2d788
@ -319,7 +319,7 @@ def load_all_installed_template_libraries():
|
|||||||
libraries = []
|
libraries = []
|
||||||
for library_name in libraries:
|
for library_name in libraries:
|
||||||
try:
|
try:
|
||||||
lib = template.get_library(library_name)
|
template.get_library(library_name)
|
||||||
except template.InvalidTemplateLibrary:
|
except template.InvalidTemplateLibrary:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ class BasePasswordHasher(object):
|
|||||||
if isinstance(self.library, (tuple, list)):
|
if isinstance(self.library, (tuple, list)):
|
||||||
name, mod_path = self.library
|
name, mod_path = self.library
|
||||||
else:
|
else:
|
||||||
name = mod_path = self.library
|
mod_path = self.library
|
||||||
try:
|
try:
|
||||||
module = importlib.import_module(mod_path)
|
module = importlib.import_module(mod_path)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
|
@ -161,7 +161,7 @@ class AuthContextProcessorTests(TestCase):
|
|||||||
# Exception RuntimeError: 'maximum recursion depth exceeded while
|
# Exception RuntimeError: 'maximum recursion depth exceeded while
|
||||||
# calling a Python object' in <type 'exceptions.AttributeError'>
|
# calling a Python object' in <type 'exceptions.AttributeError'>
|
||||||
# ignored"
|
# ignored"
|
||||||
query = Q(user=response.context['user']) & Q(someflag=True)
|
Q(user=response.context['user']) & Q(someflag=True)
|
||||||
|
|
||||||
# Tests for user equality. This is hard because User defines
|
# Tests for user equality. This is hard because User defines
|
||||||
# equality in a non-duck-typing way
|
# equality in a non-duck-typing way
|
||||||
|
@ -307,7 +307,7 @@ class UserChangeFormTest(TestCase):
|
|||||||
fields = ('groups',)
|
fields = ('groups',)
|
||||||
|
|
||||||
# Just check we can create it
|
# Just check we can create it
|
||||||
form = MyUserForm({})
|
MyUserForm({})
|
||||||
|
|
||||||
def test_unsuable_password(self):
|
def test_unsuable_password(self):
|
||||||
user = User.objects.get(username='empty_password')
|
user = User.objects.get(username='empty_password')
|
||||||
|
@ -184,7 +184,7 @@ class PasswordResetTest(AuthViewsTestCase):
|
|||||||
|
|
||||||
def _test_confirm_start(self):
|
def _test_confirm_start(self):
|
||||||
# Start by creating the email
|
# Start by creating the email
|
||||||
response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
|
self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
|
||||||
self.assertEqual(len(mail.outbox), 1)
|
self.assertEqual(len(mail.outbox), 1)
|
||||||
return self._read_signup_email(mail.outbox[0])
|
return self._read_signup_email(mail.outbox[0])
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ class ChangePasswordTest(AuthViewsTestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
response = self.client.get('/logout/')
|
self.client.get('/logout/')
|
||||||
|
|
||||||
def test_password_change_fails_with_invalid_old_password(self):
|
def test_password_change_fails_with_invalid_old_password(self):
|
||||||
self.login()
|
self.login()
|
||||||
@ -350,7 +350,7 @@ class ChangePasswordTest(AuthViewsTestCase):
|
|||||||
|
|
||||||
def test_password_change_succeeds(self):
|
def test_password_change_succeeds(self):
|
||||||
self.login()
|
self.login()
|
||||||
response = self.client.post('/password_change/', {
|
self.client.post('/password_change/', {
|
||||||
'old_password': 'password',
|
'old_password': 'password',
|
||||||
'new_password1': 'password1',
|
'new_password1': 'password1',
|
||||||
'new_password2': 'password1',
|
'new_password2': 'password1',
|
||||||
@ -465,7 +465,7 @@ class LoginTest(AuthViewsTestCase):
|
|||||||
|
|
||||||
def test_login_form_contains_request(self):
|
def test_login_form_contains_request(self):
|
||||||
# 15198
|
# 15198
|
||||||
response = self.client.post('/custom_requestauth_login/', {
|
self.client.post('/custom_requestauth_login/', {
|
||||||
'username': 'testclient',
|
'username': 'testclient',
|
||||||
'password': 'password',
|
'password': 'password',
|
||||||
}, follow=True)
|
}, follow=True)
|
||||||
|
@ -7,10 +7,9 @@ from django.conf import settings
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponseRedirect, QueryDict
|
from django.http import HttpResponseRedirect, QueryDict
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.http import base36_to_int, is_safe_url, urlsafe_base64_decode, urlsafe_base64_encode
|
from django.utils.http import is_safe_url, urlsafe_base64_decode
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.shortcuts import resolve_url
|
from django.shortcuts import resolve_url
|
||||||
from django.utils.encoding import force_bytes, force_text
|
|
||||||
from django.views.decorators.debug import sensitive_post_parameters
|
from django.views.decorators.debug import sensitive_post_parameters
|
||||||
from django.views.decorators.cache import never_cache
|
from django.views.decorators.cache import never_cache
|
||||||
from django.views.decorators.csrf import csrf_protect
|
from django.views.decorators.csrf import csrf_protect
|
||||||
|
@ -39,7 +39,7 @@ class FormPreview(object):
|
|||||||
"""
|
"""
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
f = self.form.base_fields[name]
|
self.form.base_fields[name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
break # This field name isn't being used by the form.
|
break # This field name isn't being used by the form.
|
||||||
name += '_'
|
name += '_'
|
||||||
|
@ -9,10 +9,9 @@ from django.forms.models import modelformset_factory
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.template import Template, Context
|
from django.template import Template, Context
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
|
|
||||||
from django.contrib.formtools.wizard.views import WizardView
|
from django.contrib.formtools.wizard.views import WizardView
|
||||||
|
|
||||||
|
|
||||||
temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR'))
|
temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR'))
|
||||||
temp_storage = FileSystemStorage(location=temp_storage_location)
|
temp_storage = FileSystemStorage(location=temp_storage_location)
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class GeoModelAdmin(ModelAdmin):
|
|||||||
3D editing).
|
3D editing).
|
||||||
"""
|
"""
|
||||||
if isinstance(db_field, models.GeometryField) and db_field.dim < 3:
|
if isinstance(db_field, models.GeometryField) and db_field.dim < 3:
|
||||||
request = kwargs.pop('request', None)
|
kwargs.pop('request', None)
|
||||||
# Setting the widget with the newly defined widget.
|
# Setting the widget with the newly defined widget.
|
||||||
kwargs['widget'] = self.get_map_widget(db_field)
|
kwargs['widget'] = self.get_map_widget(db_field)
|
||||||
return db_field.formfield(**kwargs)
|
return db_field.formfield(**kwargs)
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.cache import get_cache
|
from django.core.cache import get_cache
|
||||||
from django.core.cache.backends.db import BaseDatabaseCache
|
from django.core.cache.backends.db import BaseDatabaseCache
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db.backends.sqlite3.creation import DatabaseCreation
|
from django.db.backends.sqlite3.creation import DatabaseCreation
|
||||||
|
|
||||||
|
|
||||||
class SpatiaLiteCreation(DatabaseCreation):
|
class SpatiaLiteCreation(DatabaseCreation):
|
||||||
|
|
||||||
def create_test_db(self, verbosity=1, autoclobber=False):
|
def create_test_db(self, verbosity=1, autoclobber=False):
|
||||||
@ -53,8 +55,6 @@ class SpatiaLiteCreation(DatabaseCreation):
|
|||||||
interactive=False,
|
interactive=False,
|
||||||
database=self.connection.alias)
|
database=self.connection.alias)
|
||||||
|
|
||||||
from django.core.cache import get_cache
|
|
||||||
from django.core.cache.backends.db import BaseDatabaseCache
|
|
||||||
for cache_alias in settings.CACHES:
|
for cache_alias in settings.CACHES:
|
||||||
cache = get_cache(cache_alias)
|
cache = get_cache(cache_alias)
|
||||||
if isinstance(cache, BaseDatabaseCache):
|
if isinstance(cache, BaseDatabaseCache):
|
||||||
@ -62,7 +62,7 @@ class SpatiaLiteCreation(DatabaseCreation):
|
|||||||
|
|
||||||
# Get a cursor (even though we don't need one yet). This has
|
# Get a cursor (even though we don't need one yet). This has
|
||||||
# the side effect of initializing the test database.
|
# the side effect of initializing the test database.
|
||||||
cursor = self.connection.cursor()
|
self.connection.cursor()
|
||||||
|
|
||||||
return test_database_name
|
return test_database_name
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class OGRGeometry(GDALBase):
|
|||||||
else:
|
else:
|
||||||
# Seeing if the input is a valid short-hand string
|
# Seeing if the input is a valid short-hand string
|
||||||
# (e.g., 'Point', 'POLYGON').
|
# (e.g., 'Point', 'POLYGON').
|
||||||
ogr_t = OGRGeomType(geom_input)
|
OGRGeomType(geom_input)
|
||||||
g = capi.create_geom(OGRGeomType(geom_input).num)
|
g = capi.create_geom(OGRGeomType(geom_input).num)
|
||||||
elif isinstance(geom_input, memoryview):
|
elif isinstance(geom_input, memoryview):
|
||||||
# WKB was passed in
|
# WKB was passed in
|
||||||
@ -341,7 +341,7 @@ class OGRGeometry(GDALBase):
|
|||||||
sz = self.wkb_size
|
sz = self.wkb_size
|
||||||
# Creating the unsigned character buffer, and passing it in by reference.
|
# Creating the unsigned character buffer, and passing it in by reference.
|
||||||
buf = (c_ubyte * sz)()
|
buf = (c_ubyte * sz)()
|
||||||
wkb = capi.to_wkb(self.ptr, byteorder, byref(buf))
|
capi.to_wkb(self.ptr, byteorder, byref(buf))
|
||||||
# Returning a buffer of the string at the pointer.
|
# Returning a buffer of the string at the pointer.
|
||||||
return memoryview(string_at(buf, sz))
|
return memoryview(string_at(buf, sz))
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ class EnvelopeTest(unittest.TestCase):
|
|||||||
def test01_init(self):
|
def test01_init(self):
|
||||||
"Testing Envelope initilization."
|
"Testing Envelope initilization."
|
||||||
e1 = Envelope((0, 0, 5, 5))
|
e1 = Envelope((0, 0, 5, 5))
|
||||||
e2 = Envelope(0, 0, 5, 5)
|
Envelope(0, 0, 5, 5)
|
||||||
e3 = Envelope(0, '0', '5', 5) # Thanks to ww for this
|
Envelope(0, '0', '5', 5) # Thanks to ww for this
|
||||||
e4 = Envelope(e1._envelope)
|
Envelope(e1._envelope)
|
||||||
self.assertRaises(OGRException, Envelope, (5, 5, 0, 0))
|
self.assertRaises(OGRException, Envelope, (5, 5, 0, 0))
|
||||||
self.assertRaises(OGRException, Envelope, 5, 5, 0, 0)
|
self.assertRaises(OGRException, Envelope, 5, 5, 0, 0)
|
||||||
self.assertRaises(OGRException, Envelope, (0, 0, 5, 5, 3))
|
self.assertRaises(OGRException, Envelope, (0, 0, 5, 5, 3))
|
||||||
|
@ -25,15 +25,12 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
|
|||||||
"Testing OGRGeomType object."
|
"Testing OGRGeomType object."
|
||||||
|
|
||||||
# OGRGeomType should initialize on all these inputs.
|
# OGRGeomType should initialize on all these inputs.
|
||||||
try:
|
OGRGeomType(1)
|
||||||
g = OGRGeomType(1)
|
OGRGeomType(7)
|
||||||
g = OGRGeomType(7)
|
OGRGeomType('point')
|
||||||
g = OGRGeomType('point')
|
OGRGeomType('GeometrycollectioN')
|
||||||
g = OGRGeomType('GeometrycollectioN')
|
OGRGeomType('LINearrING')
|
||||||
g = OGRGeomType('LINearrING')
|
OGRGeomType('Unknown')
|
||||||
g = OGRGeomType('Unknown')
|
|
||||||
except:
|
|
||||||
self.fail('Could not create an OGRGeomType object!')
|
|
||||||
|
|
||||||
# Should throw TypeError on this input
|
# Should throw TypeError on this input
|
||||||
self.assertRaises(OGRException, OGRGeomType, 23)
|
self.assertRaises(OGRException, OGRGeomType, 23)
|
||||||
@ -127,7 +124,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
|
|||||||
def test02_points(self):
|
def test02_points(self):
|
||||||
"Testing Point objects."
|
"Testing Point objects."
|
||||||
|
|
||||||
prev = OGRGeometry('POINT(0 0)')
|
OGRGeometry('POINT(0 0)')
|
||||||
for p in self.geometries.points:
|
for p in self.geometries.points:
|
||||||
if not hasattr(p, 'z'): # No 3D
|
if not hasattr(p, 'z'): # No 3D
|
||||||
pnt = OGRGeometry(p.wkt)
|
pnt = OGRGeometry(p.wkt)
|
||||||
@ -243,7 +240,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
|
|||||||
poly = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5), (1 1, 2 1, 2 2, 2 1))')
|
poly = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5), (1 1, 2 1, 2 2, 2 1))')
|
||||||
self.assertEqual(8, poly.point_count)
|
self.assertEqual(8, poly.point_count)
|
||||||
with self.assertRaises(OGRException):
|
with self.assertRaises(OGRException):
|
||||||
_ = poly.centroid
|
poly.centroid
|
||||||
|
|
||||||
poly.close_rings()
|
poly.close_rings()
|
||||||
self.assertEqual(10, poly.point_count) # Two closing points should've been added
|
self.assertEqual(10, poly.point_count) # Two closing points should've been added
|
||||||
@ -251,7 +248,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
|
|||||||
|
|
||||||
def test08_multipolygons(self):
|
def test08_multipolygons(self):
|
||||||
"Testing MultiPolygon objects."
|
"Testing MultiPolygon objects."
|
||||||
prev = OGRGeometry('POINT(0 0)')
|
OGRGeometry('POINT(0 0)')
|
||||||
for mp in self.geometries.multipolygons:
|
for mp in self.geometries.multipolygons:
|
||||||
mpoly = OGRGeometry(mp.wkt)
|
mpoly = OGRGeometry(mp.wkt)
|
||||||
self.assertEqual(6, mpoly.geom_type)
|
self.assertEqual(6, mpoly.geom_type)
|
||||||
|
@ -58,7 +58,7 @@ class SpatialRefTest(unittest.TestCase):
|
|||||||
def test01_wkt(self):
|
def test01_wkt(self):
|
||||||
"Testing initialization on valid OGC WKT."
|
"Testing initialization on valid OGC WKT."
|
||||||
for s in srlist:
|
for s in srlist:
|
||||||
srs = SpatialReference(s.wkt)
|
SpatialReference(s.wkt)
|
||||||
|
|
||||||
def test02_bad_wkt(self):
|
def test02_bad_wkt(self):
|
||||||
"Testing initialization on invalid WKT."
|
"Testing initialization on invalid WKT."
|
||||||
@ -150,7 +150,7 @@ class SpatialRefTest(unittest.TestCase):
|
|||||||
target = SpatialReference('WGS84')
|
target = SpatialReference('WGS84')
|
||||||
for s in srlist:
|
for s in srlist:
|
||||||
if s.proj:
|
if s.proj:
|
||||||
ct = CoordTransform(SpatialReference(s.wkt), target)
|
CoordTransform(SpatialReference(s.wkt), target)
|
||||||
|
|
||||||
def test13_attr_value(self):
|
def test13_attr_value(self):
|
||||||
"Testing the attr_value() method."
|
"Testing the attr_value() method."
|
||||||
|
@ -18,7 +18,8 @@ free_regex = re.compile(r'^GEO-\d{3}FREE')
|
|||||||
lite_regex = re.compile(r'^GEO-\d{3}LITE')
|
lite_regex = re.compile(r'^GEO-\d{3}LITE')
|
||||||
|
|
||||||
#### GeoIP classes ####
|
#### GeoIP classes ####
|
||||||
class GeoIPException(Exception): pass
|
class GeoIPException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class GeoIP(object):
|
class GeoIP(object):
|
||||||
# The flags for GeoIP memory caching.
|
# The flags for GeoIP memory caching.
|
||||||
|
@ -18,7 +18,6 @@ from django.contrib.gis.geos.base import GEOSBase, gdal
|
|||||||
from django.contrib.gis.geos.coordseq import GEOSCoordSeq
|
from django.contrib.gis.geos.coordseq import GEOSCoordSeq
|
||||||
from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
|
from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
|
||||||
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOS_PREPARE
|
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOS_PREPARE
|
||||||
from django.contrib.gis.geos.mutable_list import ListMixin
|
|
||||||
|
|
||||||
# All other functions in this module come from the ctypes
|
# All other functions in this module come from the ctypes
|
||||||
# prototypes module -- which handles all interaction with
|
# prototypes module -- which handles all interaction with
|
||||||
|
@ -124,24 +124,16 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
|||||||
self.assertEqual(hexewkb_3d, pnt_3d.hexewkb)
|
self.assertEqual(hexewkb_3d, pnt_3d.hexewkb)
|
||||||
self.assertEqual(True, GEOSGeometry(hexewkb_3d).hasz)
|
self.assertEqual(True, GEOSGeometry(hexewkb_3d).hasz)
|
||||||
else:
|
else:
|
||||||
try:
|
with self.assertRaises(GEOSException):
|
||||||
hexewkb = pnt_3d.hexewkb
|
pnt_3d.hexewkb
|
||||||
except GEOSException:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.fail('Should have raised GEOSException.')
|
|
||||||
|
|
||||||
# Same for EWKB.
|
# Same for EWKB.
|
||||||
self.assertEqual(memoryview(a2b_hex(hexewkb_2d)), pnt_2d.ewkb)
|
self.assertEqual(memoryview(a2b_hex(hexewkb_2d)), pnt_2d.ewkb)
|
||||||
if GEOS_PREPARE:
|
if GEOS_PREPARE:
|
||||||
self.assertEqual(memoryview(a2b_hex(hexewkb_3d)), pnt_3d.ewkb)
|
self.assertEqual(memoryview(a2b_hex(hexewkb_3d)), pnt_3d.ewkb)
|
||||||
else:
|
else:
|
||||||
try:
|
with self.assertRaises(GEOSException):
|
||||||
ewkb = pnt_3d.ewkb
|
pnt_3d.ewkb
|
||||||
except GEOSException:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.fail('Should have raised GEOSException')
|
|
||||||
|
|
||||||
# Redundant sanity check.
|
# Redundant sanity check.
|
||||||
self.assertEqual(4326, GEOSGeometry(hexewkb_2d).srid)
|
self.assertEqual(4326, GEOSGeometry(hexewkb_2d).srid)
|
||||||
@ -158,7 +150,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
|||||||
# string-based
|
# string-based
|
||||||
for err in self.geometries.errors:
|
for err in self.geometries.errors:
|
||||||
with self.assertRaises((GEOSException, ValueError)):
|
with self.assertRaises((GEOSException, ValueError)):
|
||||||
_ = fromstr(err.wkt)
|
fromstr(err.wkt)
|
||||||
|
|
||||||
# Bad WKB
|
# Bad WKB
|
||||||
self.assertRaises(GEOSException, GEOSGeometry, memoryview(b'0'))
|
self.assertRaises(GEOSException, GEOSGeometry, memoryview(b'0'))
|
||||||
|
@ -11,7 +11,7 @@ from django.core import signals
|
|||||||
from django.core.handlers import base
|
from django.core.handlers import base
|
||||||
from django.core.urlresolvers import set_script_prefix
|
from django.core.urlresolvers import set_script_prefix
|
||||||
from django.utils import datastructures
|
from django.utils import datastructures
|
||||||
from django.utils.encoding import force_str, force_text, iri_to_uri
|
from django.utils.encoding import force_str
|
||||||
|
|
||||||
# For backwards compatibility -- lots of code uses this in the wild!
|
# For backwards compatibility -- lots of code uses this in the wild!
|
||||||
from django.http.response import REASON_PHRASES as STATUS_CODE_TEXT
|
from django.http.response import REASON_PHRASES as STATUS_CODE_TEXT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user