Fixed flake8 warnings introduced in recent commits.

This commit is contained in:
Simon Charette 2014-04-16 16:49:37 -04:00
parent 0e45669fa9
commit 79f05616fb
5 changed files with 11 additions and 14 deletions

View File

@ -4,8 +4,6 @@ PostgreSQL database backend for Django.
Requires psycopg 2: http://initd.org/projects/psycopg2 Requires psycopg 2: http://initd.org/projects/psycopg2
""" """
import sys
from django.conf import settings from django.conf import settings
from django.db.backends import (BaseDatabaseFeatures, BaseDatabaseWrapper, from django.db.backends import (BaseDatabaseFeatures, BaseDatabaseWrapper,
BaseDatabaseValidation) BaseDatabaseValidation)

View File

@ -19,40 +19,38 @@ class GetOrCreateTests(TestCase):
) )
def test_get_or_create_method_with_get(self): def test_get_or_create_method_with_get(self):
p, created = Person.objects.get_or_create( created = Person.objects.get_or_create(
first_name="John", last_name="Lennon", defaults={ first_name="John", last_name="Lennon", defaults={
"birthday": date(1940, 10, 9) "birthday": date(1940, 10, 9)
} }
) )[1]
self.assertFalse(created) self.assertFalse(created)
self.assertEqual(Person.objects.count(), 1) self.assertEqual(Person.objects.count(), 1)
def test_get_or_create_method_with_create(self): def test_get_or_create_method_with_create(self):
p, created = Person.objects.get_or_create( created = Person.objects.get_or_create(
first_name='George', last_name='Harrison', defaults={ first_name='George', last_name='Harrison', defaults={
'birthday': date(1943, 2, 25) 'birthday': date(1943, 2, 25)
} }
) )[1]
self.assertTrue(created) self.assertTrue(created)
self.assertEqual(Person.objects.count(), 2) self.assertEqual(Person.objects.count(), 2)
def test_get_or_create_redundant_instance(self): def test_get_or_create_redundant_instance(self):
""" """
If we execute the exact same statement twice, the second time, If we execute the exact same statement twice, the second time,
it won't create a Person. it won't create a Person.
""" """
george, created = Person.objects.get_or_create( Person.objects.get_or_create(
first_name='George', last_name='Harrison', defaults={ first_name='George', last_name='Harrison', defaults={
'birthday': date(1943, 2, 25) 'birthday': date(1943, 2, 25)
} }
) )
evil_george, created = Person.objects.get_or_create( created = Person.objects.get_or_create(
first_name='George', last_name='Harrison', defaults={ first_name='George', last_name='Harrison', defaults={
'birthday': date(1943, 2, 25) 'birthday': date(1943, 2, 25)
} }
) )[1]
self.assertFalse(created) self.assertFalse(created)
self.assertEqual(Person.objects.count(), 2) self.assertEqual(Person.objects.count(), 2)
@ -67,6 +65,7 @@ class GetOrCreateTests(TestCase):
Person.objects.get_or_create, first_name="Tom", last_name="Smith" Person.objects.get_or_create, first_name="Tom", last_name="Smith"
) )
class GetOrCreateTestsWithManualPKs(TestCase): class GetOrCreateTestsWithManualPKs(TestCase):
def setUp(self): def setUp(self):

View File

@ -1066,7 +1066,7 @@ class Ticket21760Tests(TestCase):
for _ in range(3): for _ in range(3):
house = House.objects.create() house = House.objects.create()
for _ in range(3): for _ in range(3):
self.rooms.append(Room.objects.create(house = house)) self.rooms.append(Room.objects.create(house=house))
def test_bug(self): def test_bug(self):
prefetcher = get_prefetcher(self.rooms[0], 'house')[0] prefetcher = get_prefetcher(self.rooms[0], 'house')[0]

View File

@ -3,6 +3,7 @@ Doctest example from the official Python documentation.
https://docs.python.org/3/library/doctest.html https://docs.python.org/3/library/doctest.html
""" """
def factorial(n): def factorial(n):
"""Return the factorial of n, an exact integer >= 0. """Return the factorial of n, an exact integer >= 0.
@ -35,7 +36,7 @@ def factorial(n):
raise ValueError("n must be >= 0") raise ValueError("n must be >= 0")
if math.floor(n) != n: if math.floor(n) != n:
raise ValueError("n must be exact integer") raise ValueError("n must be exact integer")
if n+1 == n: # catch a value like 1e300 if n + 1 == n: # catch a value like 1e300
raise OverflowError("n too large") raise OverflowError("n too large")
result = 1 result = 1
factor = 2 factor = 2

View File

@ -105,7 +105,6 @@ class DiscoverRunnerTest(TestCase):
def test_testcase_ordering(self): def test_testcase_ordering(self):
suite = DiscoverRunner().build_suite(["test_discovery_sample/"]) suite = DiscoverRunner().build_suite(["test_discovery_sample/"])
tc_names = [case.__class__.__name__ for case in suite._tests]
self.assertEqual( self.assertEqual(
suite._tests[0].__class__.__name__, suite._tests[0].__class__.__name__,
'TestDjangoTestCase', 'TestDjangoTestCase',