Skip to content

Commit

Permalink
Use nested calls to TestCase.subTest
Browse files Browse the repository at this point in the history
  • Loading branch information
finefoot authored May 16, 2022
1 parent 7cc9fc8 commit 61a6b5a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Lib/test/test_reprlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,15 @@ def test_valid_indent(self):
},
]
for test_case in test_cases:
for repr_settings, expected_repr in test_case['tests']:
with self.subTest(
test_object=test_case['object'], repr_settings=repr_settings
):
r = Repr()
for attribute, value in repr_settings.items():
setattr(r, attribute, value)
expected_repr = textwrap.dedent(expected_repr)
self.assertEqual(r.repr(test_case['object']), expected_repr)
with self.subTest(test_object=test_case['object']):
for repr_settings, expected_repr in test_case['tests']:
with self.subTest(repr_settings=repr_settings):
r = Repr()
for attribute, value in repr_settings.items():
setattr(r, attribute, value)
resulting_repr = r.repr(test_case['object'])
expected_repr = textwrap.dedent(expected_repr)
self.assertEqual(resulting_repr, expected_repr)

def test_invalid_indent(self):
test_object = [1, 'spam', {'eggs': True, 'ham': []}]
Expand Down

0 comments on commit 61a6b5a

Please sign in to comment.