Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77203ad

Browse files
committed
Ignore the exact ID value for the nested function in the dis.code_info tests
1 parent fc8b205 commit 77203ad

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Lib/test/test_dis.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def f(c=c):
259259
Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, GENERATOR
260260
Constants:
261261
0: None
262-
1: <code object f at {1}, file "{0}", line {2}>
262+
1: <code object f at (.*), file "{0}", line {1}>
263263
Variable names:
264264
0: x
265265
1: y
@@ -276,7 +276,6 @@ def f(c=c):
276276
3: y
277277
4: x
278278
5: z""".format(__file__,
279-
hex(id(co_tricky_nested_f)),
280279
co_tricky_nested_f.co_firstlineno)
281280

282281
code_info_tricky_nested_f = """\
@@ -356,14 +355,14 @@ class CodeInfoTests(unittest.TestCase):
356355
def test_code_info(self):
357356
self.maxDiff = 1000
358357
for x, expected in self.test_pairs:
359-
self.assertEqual(dis.code_info(x), expected)
358+
self.assertRegexpMatches(dis.code_info(x), expected)
360359

361360
def test_show_code(self):
362361
self.maxDiff = 1000
363362
for x, expected in self.test_pairs:
364363
with captured_stdout() as output:
365364
dis.show_code(x)
366-
self.assertEqual(output.getvalue(), expected+"\n")
365+
self.assertRegexpMatches(output.getvalue(), expected+"\n")
367366

368367
def test_main():
369368
run_unittest(DisTests, CodeInfoTests)

0 commit comments

Comments
 (0)