diff --git a/tests/get_earliest_or_latest/tests.py b/tests/get_earliest_or_latest/tests.py index e03f701da6..27c3c34723 100644 --- a/tests/get_earliest_or_latest/tests.py +++ b/tests/get_earliest_or_latest/tests.py @@ -111,8 +111,9 @@ class EarliestOrLatestTests(TestCase): Article.objects.model._meta.get_latest_by = None with self.assertRaisesMessage( AssertionError, - "earliest() and latest() require either a field_name parameter or " - "'get_latest_by' in the model"): + "earliest() and latest() require either a field_name parameter or " + "'get_latest_by' in the model" + ): Article.objects.latest() def test_latest_manual(self): diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py index 60db33e0bd..8dfa2876c8 100644 --- a/tests/httpwrappers/tests.py +++ b/tests/httpwrappers/tests.py @@ -508,9 +508,11 @@ class JsonResponseTests(SimpleTestCase): self.assertEqual(json.loads(response.content.decode()), data) def test_json_response_raises_type_error_with_default_setting(self): - with self.assertRaisesMessage(TypeError, - 'In order to allow non-dict objects to be serialized set the ' - 'safe parameter to False'): + with self.assertRaisesMessage( + TypeError, + 'In order to allow non-dict objects to be serialized set the ' + 'safe parameter to False' + ): JsonResponse([1, 2, 3]) def test_json_response_text(self): diff --git a/tests/queries/tests.py b/tests/queries/tests.py index f1acd69067..91ff7bfc8d 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -1318,12 +1318,10 @@ class Queries3Tests(BaseQuerysetTest): Item.objects.datetimes('name', 'month') def test_ticket22023(self): - with self.assertRaisesMessage(TypeError, - "Cannot call only() after .values() or .values_list()"): + with self.assertRaisesMessage(TypeError, "Cannot call only() after .values() or .values_list()"): Valid.objects.values().only() - with self.assertRaisesMessage(TypeError, - "Cannot call defer() after .values() or .values_list()"): + with self.assertRaisesMessage(TypeError, "Cannot call defer() after .values() or .values_list()"): Valid.objects.values().defer() @@ -2244,9 +2242,8 @@ class ValuesQuerysetTests(BaseQuerysetTest): def test_field_error_values_list(self): # see #23443 - with self.assertRaisesMessage(FieldError, - "Cannot resolve keyword %r into field." - " Join on 'name' not permitted." % 'foo'): + msg = "Cannot resolve keyword %r into field. Join on 'name' not permitted." % 'foo' + with self.assertRaisesMessage(FieldError, msg): Tag.objects.values_list('name__foo') @@ -3462,25 +3459,20 @@ class RelatedLookupTypeTests(TestCase): query lookup. """ # Passing incorrect object type - with self.assertRaisesMessage(ValueError, - self.error % (self.wrong_type, ObjectA._meta.object_name)): + with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectA._meta.object_name)): ObjectB.objects.get(objecta=self.wrong_type) - with self.assertRaisesMessage(ValueError, - self.error % (self.wrong_type, ObjectA._meta.object_name)): + with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectA._meta.object_name)): ObjectB.objects.filter(objecta__in=[self.wrong_type]) - with self.assertRaisesMessage(ValueError, - self.error % (self.wrong_type, ObjectA._meta.object_name)): + with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectA._meta.object_name)): ObjectB.objects.filter(objecta=self.wrong_type) - with self.assertRaisesMessage(ValueError, - self.error % (self.wrong_type, ObjectB._meta.object_name)): + with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectB._meta.object_name)): ObjectA.objects.filter(objectb__in=[self.wrong_type, self.ob]) # Passing an object of the class on which query is done. - with self.assertRaisesMessage(ValueError, - self.error % (self.ob, ObjectA._meta.object_name)): + with self.assertRaisesMessage(ValueError, self.error % (self.ob, ObjectA._meta.object_name)): ObjectB.objects.filter(objecta__in=[self.poa, self.ob]) with self.assertRaisesMessage(ValueError, @@ -3492,16 +3484,13 @@ class RelatedLookupTypeTests(TestCase): A ValueError is raised when the incorrect object type is passed to a query lookup for backward relations. """ - with self.assertRaisesMessage(ValueError, - self.error % (self.oa, ObjectB._meta.object_name)): + with self.assertRaisesMessage(ValueError, self.error % (self.oa, ObjectB._meta.object_name)): ObjectA.objects.filter(objectb__in=[self.oa, self.ob]) - with self.assertRaisesMessage(ValueError, - self.error % (self.oa, ObjectB._meta.object_name)): + with self.assertRaisesMessage(ValueError, self.error % (self.oa, ObjectB._meta.object_name)): ObjectA.objects.exclude(objectb=self.oa) - with self.assertRaisesMessage(ValueError, - self.error % (self.wrong_type, ObjectB._meta.object_name)): + with self.assertRaisesMessage(ValueError, self.error % (self.wrong_type, ObjectB._meta.object_name)): ObjectA.objects.get(objectb=self.wrong_type) def test_correct_lookup(self): diff --git a/tests/syndication_tests/tests.py b/tests/syndication_tests/tests.py index 870df35bd5..6f4655838a 100644 --- a/tests/syndication_tests/tests.py +++ b/tests/syndication_tests/tests.py @@ -195,10 +195,11 @@ class SyndicationFeedTest(FeedTestCase): self.assertEqual(len(enclosures), 1) def test_rss2_multiple_enclosures(self): - with self.assertRaisesMessage(ValueError, ( + with self.assertRaisesMessage( + ValueError, "RSS feed items may only have one enclosure, see " "http://www.rssboard.org/rss-profile#element-channel-item-enclosure" - )): + ): self.client.get('/syndication/rss2/multiple-enclosure/') def test_rss091_feed(self): @@ -530,9 +531,8 @@ class SyndicationFeedTest(FeedTestCase): class FeedgeneratorTestCase(TestCase): def test_add_item_warns_when_enclosure_kwarg_is_used(self): feed = SyndicationFeed(title='Example', link='http://example.com', description='Foo') - with self.assertRaisesMessage(RemovedInDjango20Warning, ( - 'The enclosure keyword argument is deprecated, use enclosures instead.' - )): + msg = 'The enclosure keyword argument is deprecated, use enclosures instead.' + with self.assertRaisesMessage(RemovedInDjango20Warning, msg): feed.add_item( title='Example Item', link='https://example.com/item',