1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

PEP 8 cleanup

This commit is contained in:
Anssi Kääriäinen 2013-06-05 21:16:16 +03:00
parent bb863faecd
commit 8c5b805ca1

View File

@ -2,7 +2,8 @@ from django.db.models import Q
from django.db.utils import IntegrityError
from django.test import TestCase, skipIfDBFeature
from .models import (Address, Place, Restaurant, Link, CharLink, TextLink,
from .models import (
Address, Place, Restaurant, Link, CharLink, TextLink,
Person, Contact, Note, Organization, OddRelation1, OddRelation2, Company,
Developer, Team, Guild, Tag, Board, HasLinkThing)
@ -28,9 +29,9 @@ class GenericRelationTests(TestCase):
originating model of a query. See #12664.
"""
p = Person.objects.create(account=23, name='Chef')
a = Address.objects.create(street='123 Anywhere Place',
city='Conifer', state='CO',
zipcode='80433', content_object=p)
Address.objects.create(street='123 Anywhere Place',
city='Conifer', state='CO',
zipcode='80433', content_object=p)
qs = Person.objects.filter(addresses__zipcode='80433')
self.assertEqual(1, qs.count())
@ -38,12 +39,12 @@ class GenericRelationTests(TestCase):
def test_charlink_delete(self):
oddrel = OddRelation1.objects.create(name='clink')
cl = CharLink.objects.create(content_object=oddrel)
CharLink.objects.create(content_object=oddrel)
oddrel.delete()
def test_textlink_delete(self):
oddrel = OddRelation2.objects.create(name='tlink')
tl = TextLink.objects.create(content_object=oddrel)
TextLink.objects.create(content_object=oddrel)
oddrel.delete()
def test_q_object_or(self):
@ -61,12 +62,12 @@ class GenericRelationTests(TestCase):
"""
note_contact = Contact.objects.create()
org_contact = Contact.objects.create()
note = Note.objects.create(note='note', content_object=note_contact)
Note.objects.create(note='note', content_object=note_contact)
org = Organization.objects.create(name='org name')
org.contacts.add(org_contact)
# search with a non-matching note and a matching org name
qs = Contact.objects.filter(Q(notes__note__icontains=r'other note') |
Q(organizations__name__icontains=r'org name'))
Q(organizations__name__icontains=r'org name'))
self.assertTrue(org_contact in qs)
# search again, with the same query parameters, in reverse order
qs = Contact.objects.filter(
@ -90,8 +91,8 @@ class GenericRelationTests(TestCase):
p1 = Place.objects.create(name="South Park")
p2 = Place.objects.create(name="The City")
c = Company.objects.create(name="Chubby's Intl.")
l1 = Link.objects.create(content_object=p1)
l2 = Link.objects.create(content_object=c)
Link.objects.create(content_object=p1)
Link.objects.create(content_object=c)
places = list(Place.objects.order_by('links__id'))
def count_places(place):
@ -114,8 +115,10 @@ class GenericRelationTests(TestCase):
try:
note = Note(note='Deserve a bonus', content_object=team1)
except Exception as e:
if issubclass(type(e), Exception) and str(e) == 'Impossible arguments to GFK.get_content_type!':
self.fail("Saving model with GenericForeignKey to model instance whose __len__ method returns 0 shouldn't fail.")
if (issubclass(type(e), Exception) and
str(e) == 'Impossible arguments to GFK.get_content_type!'):
self.fail("Saving model with GenericForeignKey to model instance whose "
"__len__ method returns 0 shouldn't fail.")
raise e
note.save()