1
0
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:
Alex Gaynor
2013-09-08 08:05:16 -07:00
parent 0ee8aa5c39
commit 96fd5557f9
18 changed files with 47 additions and 68 deletions

View File

@@ -160,7 +160,7 @@ class ChangeListTests(TestCase):
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 @@ class ChangeListTests(TestCase):
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)

View File

@@ -8,11 +8,11 @@ from django.test import TestCase
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 @@ class TestInline(TestCase):
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 @@ class TestInline(TestCase):
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 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
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/'))

View File

@@ -106,7 +106,6 @@ class AdminScriptTestCase(unittest.TestCase):
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__))

View File

@@ -377,9 +377,9 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
(AdminOrderedAdminMethod, 'adminorderedadminmethod'),
(AdminOrderedCallable, 'adminorderedcallable')]
for model, url in models:
a1 = model.objects.create(stuff='The Last Item', order=3)
a2 = model.objects.create(stuff='The First Item', order=1)
a3 = model.objects.create(stuff='The Middle Item', order=2)
model.objects.create(stuff='The Last Item', order=3)
model.objects.create(stuff='The First Item', order=1)
model.objects.create(stuff='The Middle Item', order=2)
response = self.client.get('/test_admin/admin/admin_views/%s/' % url, {})
self.assertEqual(response.status_code, 200)
# Should have 3 columns including action checkbox col.
@@ -596,7 +596,6 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
(against 9bea85795705d015cdadc82c68b99196a8554f5c)
"""
user = User.objects.get(username='super')
password = user.password
user.set_unusable_password()
user.save()
@@ -734,7 +733,7 @@ class SaveAsTests(TestCase):
def test_save_as_duplication(self):
"""Ensure save as actually creates a new person"""
post_data = {'_saveasnew': '', 'name': 'John M', 'gender': 1, 'age': 42}
response = self.client.post('/test_admin/admin/admin_views/person/1/', post_data)
self.client.post('/test_admin/admin/admin_views/person/1/', post_data)
self.assertEqual(len(Person.objects.filter(name='John M')), 1)
self.assertEqual(len(Person.objects.filter(id=1)), 1)
@@ -1065,7 +1064,7 @@ class AdminViewPermissionsTest(TestCase):
# 8509 - if a normal user is already logged in, it is possible
# to change user into the superuser without error
login = self.client.login(username='joepublic', password='secret')
self.client.login(username='joepublic', password='secret')
# Check and make sure that if user expires, data still persists
self.client.get('/test_admin/admin/')
self.client.post('/test_admin/admin/', self.super_login)
@@ -1442,7 +1441,7 @@ class AdminViewDeletedObjectsTest(TestCase):
"""
plot = Plot.objects.get(pk=3)
tag = FunkyTag.objects.create(content_object=plot, name='hott')
FunkyTag.objects.create(content_object=plot, name='hott')
should_contain = """<li>Funky tag: hott"""
response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(3))
self.assertContains(response, should_contain)
@@ -2222,8 +2221,8 @@ class AdminSearchTest(TestCase):
self.assertNotContains(response, "Guido")
def test_pluggable_search(self):
p1 = PluggableSearchPerson.objects.create(name="Bob", age=10)
p2 = PluggableSearchPerson.objects.create(name="Amy", age=20)
PluggableSearchPerson.objects.create(name="Bob", age=10)
PluggableSearchPerson.objects.create(name="Amy", age=20)
response = self.client.get('/test_admin/admin/admin_views/pluggablesearchperson/?q=Bob')
# confirm the search returned one object
@@ -2342,7 +2341,7 @@ class AdminActionsTest(TestCase):
'action': 'mail_admin',
'index': 0,
}
response = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)
self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].subject, 'Greetings from a ModelAdmin action')
@@ -2362,7 +2361,7 @@ class AdminActionsTest(TestCase):
self.assertIsInstance(confirmation, TemplateResponse)
self.assertContains(confirmation, "Are you sure you want to delete the selected subscribers?")
self.assertContains(confirmation, ACTION_CHECKBOX_NAME, count=2)
response = self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
self.assertEqual(Subscriber.objects.count(), 0)
def test_non_localized_pk(self):
@@ -2538,7 +2537,7 @@ action)</option>
# ...but we clicked "go" on the top form.
'index': 0
}
response = self.client.post('/test_admin/admin/admin_views/externalsubscriber/', action_data)
self.client.post('/test_admin/admin/admin_views/externalsubscriber/', action_data)
# Send mail, don't delete.
self.assertEqual(len(mail.outbox), 1)