diff --git a/tests/cache/tests.py b/tests/cache/tests.py index dc4c69cd43..f0e55ced29 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -560,7 +560,7 @@ class BaseCacheTests(object): # Count how many keys are left in the cache. for i in range(1, initial_count): if cull_cache.has_key('cull%d' % i): - count = count + 1 + count += 1 self.assertEqual(count, final_count) def test_cull(self): diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py index d432a5d2d9..2cd86342b9 100644 --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -1316,10 +1316,10 @@ class TestIsBoundBehavior(SimpleTestCase): unbound_formset = ArticleFormSet() bound_formset = ArticleFormSet(data) - empty_forms = [] - - empty_forms.append(unbound_formset.empty_form) - empty_forms.append(bound_formset.empty_form) + empty_forms = [ + unbound_formset.empty_form, + bound_formset.empty_form + ] # Empty forms should be unbound self.assertFalse(empty_forms[0].is_bound) diff --git a/tests/migrate_signals/tests.py b/tests/migrate_signals/tests.py index a47d5f9ab9..d422ab84b4 100644 --- a/tests/migrate_signals/tests.py +++ b/tests/migrate_signals/tests.py @@ -19,7 +19,7 @@ class Receiver(object): signal.connect(self, sender=APP_CONFIG) def __call__(self, signal, sender, **kwargs): - self.call_counter = self.call_counter + 1 + self.call_counter += 1 self.call_args = kwargs @@ -39,7 +39,7 @@ class OneTimeReceiver(object): # Although test runner calls migrate for several databases, # testing for only one of them is quite sufficient. if kwargs['using'] == MIGRATE_DATABASE: - self.call_counter = self.call_counter + 1 + self.call_counter += 1 self.call_args = kwargs # we need to test only one call of migrate self.signal.disconnect(self, sender=APP_CONFIG) diff --git a/tests/runtests.py b/tests/runtests.py index 2f9cabb6e5..be317d347b 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -330,11 +330,11 @@ def bisect_tests(bisection_label, options, test_labels, parallel): if failures_a and not failures_b: print("***** Problem found in first half. Bisecting again...") - iteration = iteration + 1 + iteration += 1 test_labels = test_labels_a[:-1] elif failures_b and not failures_a: print("***** Problem found in second half. Bisecting again...") - iteration = iteration + 1 + iteration += 1 test_labels = test_labels_b[:-1] elif failures_a and failures_b: print("***** Multiple sources of failure found") diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py index 1921c6a30c..d448e55869 100644 --- a/tests/user_commands/tests.py +++ b/tests/user_commands/tests.py @@ -146,7 +146,7 @@ class CommandTests(SimpleTestCase): self.counter = 0 def patched_check(self_, **kwargs): - self.counter = self.counter + 1 + self.counter += 1 saved_check = BaseCommand.check BaseCommand.check = patched_check diff --git a/tests/utils_tests/test_lazyobject.py b/tests/utils_tests/test_lazyobject.py index 62d7964fcf..36135e6fc6 100644 --- a/tests/utils_tests/test_lazyobject.py +++ b/tests/utils_tests/test_lazyobject.py @@ -103,8 +103,7 @@ class LazyObjectTestCase(TestCase): def test_hash(self): obj = self.lazy_wrap('foo') - d = {} - d[obj] = 'bar' + d = {obj: 'bar'} self.assertIn('foo', d) self.assertEqual(d['foo'], 'bar')