mirror of
https://github.com/django/django.git
synced 2025-10-08 09:40:35 +00:00
Refs #26022 -- Used context manager version of assertRaisesMessage in tests.
This commit is contained in:
parent
3d0dcd7f5a
commit
253adc2b8a
21 changed files with 584 additions and 566 deletions
|
@ -108,8 +108,8 @@ class ImmutableListTests(SimpleTestCase):
|
|||
d = ImmutableList(range(10))
|
||||
|
||||
# AttributeError: ImmutableList object is immutable.
|
||||
self.assertRaisesMessage(AttributeError,
|
||||
'ImmutableList object is immutable.', d.sort)
|
||||
with self.assertRaisesMessage(AttributeError, 'ImmutableList object is immutable.'):
|
||||
d.sort()
|
||||
|
||||
self.assertEqual(repr(d), '(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)')
|
||||
|
||||
|
@ -119,8 +119,8 @@ class ImmutableListTests(SimpleTestCase):
|
|||
self.assertEqual(d[1], 1)
|
||||
|
||||
# AttributeError: Object is immutable!
|
||||
self.assertRaisesMessage(AttributeError,
|
||||
'Object is immutable!', d.__setitem__, 1, 'test')
|
||||
with self.assertRaisesMessage(AttributeError, 'Object is immutable!'):
|
||||
d.__setitem__(1, 'test')
|
||||
|
||||
|
||||
class DictWrapperTests(SimpleTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue