mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Removed unused local variables in tests.
This commit is contained in:
@@ -384,14 +384,12 @@ class QueryTestCase(TestCase):
|
||||
pro = Book.objects.create(title="Pro Django",
|
||||
published=datetime.date(2008, 12, 16))
|
||||
|
||||
marty = Person.objects.create(name="Marty Alchin")
|
||||
george = Person.objects.create(name="George Vilches")
|
||||
|
||||
# Create a book and author on the other database
|
||||
dive = Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4))
|
||||
|
||||
mark = Person.objects.using('other').create(name="Mark Pilgrim")
|
||||
chris = Person.objects.using('other').create(name="Chris Mills")
|
||||
|
||||
# Save the author's favourite books
|
||||
@@ -431,7 +429,6 @@ class QueryTestCase(TestCase):
|
||||
dive = Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4))
|
||||
|
||||
mark = Person.objects.using('other').create(name="Mark Pilgrim")
|
||||
chris = Person.objects.using('other').create(name="Chris Mills")
|
||||
|
||||
# Save the author relations
|
||||
@@ -561,7 +558,7 @@ class QueryTestCase(TestCase):
|
||||
def test_foreign_key_deletion(self):
|
||||
"Cascaded deletions of Foreign Key relations issue queries on the right database"
|
||||
mark = Person.objects.using('other').create(name="Mark Pilgrim")
|
||||
fido = Pet.objects.using('other').create(name="Fido", owner=mark)
|
||||
Pet.objects.using('other').create(name="Fido", owner=mark)
|
||||
|
||||
# Check the initial state
|
||||
self.assertEqual(Person.objects.using('default').count(), 0)
|
||||
@@ -779,7 +776,7 @@ class QueryTestCase(TestCase):
|
||||
dive = Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4))
|
||||
|
||||
review2 = Review.objects.using('other').create(source="Python Weekly", content_object=dive)
|
||||
Review.objects.using('other').create(source="Python Weekly", content_object=dive)
|
||||
|
||||
# Set a foreign key with an object from a different database
|
||||
try:
|
||||
@@ -822,7 +819,7 @@ class QueryTestCase(TestCase):
|
||||
"Cascaded deletions of Generic Key relations issue queries on the right database"
|
||||
dive = Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4))
|
||||
review = Review.objects.using('other').create(source="Python Weekly", content_object=dive)
|
||||
Review.objects.using('other').create(source="Python Weekly", content_object=dive)
|
||||
|
||||
# Check the initial state
|
||||
self.assertEqual(Book.objects.using('default').count(), 0)
|
||||
@@ -843,7 +840,7 @@ class QueryTestCase(TestCase):
|
||||
|
||||
def test_ordering(self):
|
||||
"get_next_by_XXX commands stick to a single database"
|
||||
pro = Book.objects.create(title="Pro Django",
|
||||
Book.objects.create(title="Pro Django",
|
||||
published=datetime.date(2008, 12, 16))
|
||||
|
||||
dive = Book.objects.using('other').create(title="Dive into Python",
|
||||
@@ -869,9 +866,9 @@ class QueryTestCase(TestCase):
|
||||
"Database assignment is retained if an object is retrieved with select_related()"
|
||||
# Create a book and author on the other database
|
||||
mark = Person.objects.using('other').create(name="Mark Pilgrim")
|
||||
dive = Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4),
|
||||
editor=mark)
|
||||
Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4),
|
||||
editor=mark)
|
||||
|
||||
# Retrieve the Person using select_related()
|
||||
book = Book.objects.using('other').select_related('editor').get(title="Dive into Python")
|
||||
@@ -1033,8 +1030,8 @@ class RouterTestCase(TestCase):
|
||||
pro.authors = [marty]
|
||||
|
||||
# Create a book and author on the other database
|
||||
dive = Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4))
|
||||
Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4))
|
||||
|
||||
# An update query will be routed to the default database
|
||||
Book.objects.filter(title='Pro Django').update(pages=200)
|
||||
@@ -1443,8 +1440,6 @@ class RouterTestCase(TestCase):
|
||||
published=datetime.date(2008, 12, 16))
|
||||
|
||||
marty = Person.objects.using('other').create(pk=1, name="Marty Alchin")
|
||||
pro_authors = pro.authors.using('other')
|
||||
authors = [marty]
|
||||
|
||||
self.assertEqual(pro.authors.db, 'other')
|
||||
self.assertEqual(pro.authors.db_manager('default').db, 'default')
|
||||
@@ -1457,9 +1452,9 @@ class RouterTestCase(TestCase):
|
||||
def test_foreign_key_managers(self):
|
||||
"FK reverse relations are represented by managers, and can be controlled like managers"
|
||||
marty = Person.objects.using('other').create(pk=1, name="Marty Alchin")
|
||||
pro = Book.objects.using('other').create(pk=1, title="Pro Django",
|
||||
published=datetime.date(2008, 12, 16),
|
||||
editor=marty)
|
||||
Book.objects.using('other').create(pk=1, title="Pro Django",
|
||||
published=datetime.date(2008, 12, 16),
|
||||
editor=marty)
|
||||
|
||||
self.assertEqual(marty.edited.db, 'other')
|
||||
self.assertEqual(marty.edited.db_manager('default').db, 'default')
|
||||
@@ -1470,8 +1465,8 @@ class RouterTestCase(TestCase):
|
||||
pro = Book.objects.using('other').create(title="Pro Django",
|
||||
published=datetime.date(2008, 12, 16))
|
||||
|
||||
review1 = Review.objects.using('other').create(source="Python Monthly",
|
||||
content_object=pro)
|
||||
Review.objects.using('other').create(source="Python Monthly",
|
||||
content_object=pro)
|
||||
|
||||
self.assertEqual(pro.reviews.db, 'other')
|
||||
self.assertEqual(pro.reviews.db_manager('default').db, 'default')
|
||||
@@ -1482,9 +1477,9 @@ class RouterTestCase(TestCase):
|
||||
# Create a book and author on the other database
|
||||
|
||||
mark = Person.objects.using('other').create(name="Mark Pilgrim")
|
||||
dive = Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4),
|
||||
editor=mark)
|
||||
Book.objects.using('other').create(title="Dive into Python",
|
||||
published=datetime.date(2009, 5, 4),
|
||||
editor=mark)
|
||||
|
||||
sub = Person.objects.filter(name='Mark Pilgrim')
|
||||
qs = Book.objects.filter(editor__in=sub)
|
||||
@@ -1857,7 +1852,7 @@ class RouterModelArgumentTestCase(TestCase):
|
||||
|
||||
def test_foreignkey_collection(self):
|
||||
person = Person.objects.create(name='Bob')
|
||||
pet = Pet.objects.create(owner=person, name='Wart')
|
||||
Pet.objects.create(owner=person, name='Wart')
|
||||
# test related FK collection
|
||||
person.delete()
|
||||
|
||||
@@ -1967,7 +1962,7 @@ class RouteForWriteTestCase(TestCase):
|
||||
|
||||
def test_reverse_fk_update(self):
|
||||
owner = Person.objects.create(name='Someone')
|
||||
pet = Pet.objects.create(name='fido', owner=owner)
|
||||
Pet.objects.create(name='fido', owner=owner)
|
||||
self.enable_router()
|
||||
try:
|
||||
owner.pet_set.update(name='max')
|
||||
@@ -2019,7 +2014,7 @@ class RouteForWriteTestCase(TestCase):
|
||||
self.assertEqual(e.hints, {'instance': book})
|
||||
|
||||
def test_m2m_get_or_create(self):
|
||||
auth = Person.objects.create(name='Someone')
|
||||
Person.objects.create(name='Someone')
|
||||
book = Book.objects.create(title="Pro Django",
|
||||
published=datetime.date(2008, 12, 16))
|
||||
self.enable_router()
|
||||
@@ -2103,8 +2098,8 @@ class RouteForWriteTestCase(TestCase):
|
||||
|
||||
def test_reverse_m2m_get_or_create(self):
|
||||
auth = Person.objects.create(name='Someone')
|
||||
book = Book.objects.create(title="Pro Django",
|
||||
published=datetime.date(2008, 12, 16))
|
||||
Book.objects.create(title="Pro Django",
|
||||
published=datetime.date(2008, 12, 16))
|
||||
self.enable_router()
|
||||
try:
|
||||
auth.book_set.get_or_create(title="New Book", published=datetime.datetime.now())
|
||||
|
||||
Reference in New Issue
Block a user