Made multiline assertRaises* conform to flake8's E128 rule.
This commit is contained in:
parent
6eb3ce11e4
commit
04de436932
|
@ -112,7 +112,8 @@ class EarliestOrLatestTests(TestCase):
|
|||
with self.assertRaisesMessage(
|
||||
AssertionError,
|
||||
"earliest() and latest() require either a field_name parameter or "
|
||||
"'get_latest_by' in the model"):
|
||||
"'get_latest_by' in the model"
|
||||
):
|
||||
Article.objects.latest()
|
||||
|
||||
def test_latest_manual(self):
|
||||
|
|
|
@ -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,
|
||||
with self.assertRaisesMessage(
|
||||
TypeError,
|
||||
'In order to allow non-dict objects to be serialized set the '
|
||||
'safe parameter to False'):
|
||||
'safe parameter to False'
|
||||
):
|
||||
JsonResponse([1, 2, 3])
|
||||
|
||||
def test_json_response_text(self):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue