Skip to content

Commit

Permalink
pythongh-125038: Test improvement, assertRaisesRegex is used
Browse files Browse the repository at this point in the history
  • Loading branch information
efimov-mikhail committed Oct 7, 2024
1 parent d3d5b39 commit c353cf1
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Lib/test/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,9 @@ def get_generator():
g.gi_frame.f_locals['.0'] = range(20)
return g

def genexpr_to_list():
try:
l = list(get_generator())
return "NoError"
except TypeError:
return "TypeError"

# This should not raise
r = genexpr_to_list()

self.assertIs(r, "TypeError")
err_msg = "'for' requires an object with __iter__ method, got range"
with self.assertRaisesRegex(TypeError, err_msg):
l = list(get_generator())

class ExceptionTest(unittest.TestCase):
# Tests for the issue #23353: check that the currently handled exception
Expand Down

0 comments on commit c353cf1

Please sign in to comment.