Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Correction: It is possible to assert both warnings and errors in tandem
  • Loading branch information
TabLand committed Sep 3, 2023
commit 121948a5abc45f75f07927fcebeb0272392de315
6 changes: 4 additions & 2 deletions Lib/test/test_sys_settrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,8 @@ def run_test(self, func, jumpFrom, jumpTo, expected, error=None,
with self.assertRaisesRegex(*error):
func(output)
else:
raise NotImplementedError("Not currently possible to assert both a warning and an error in tandem, as one will be ignored by the unittest framework")
with self.assertRaisesRegex(*error) as error_context, self.assertWarnsRegex(*warning) as warning_context:
func(output)

sys.settrace(None)
self.compare_jump_output(expected, output)
Expand All @@ -1969,7 +1970,8 @@ def run_async_test(self, func, jumpFrom, jumpTo, expected, error=None,
with self.assertRaisesRegex(*error):
asyncio.run(func(output))
else:
raise NotImplementedError("Not currently possible to assert both a warning and an error in tandem, as one will be ignored by the unittest framework")
with self.assertRaisesRegex(*error) as error_context, self.assertWarnsRegex(*warning) as warning_context:
func(output)

sys.settrace(None)
asyncio.set_event_loop_policy(None)
Expand Down