Commit 0a001f86 authored by Nick Coghlan's avatar Nick Coghlan

Ignore the exact ID value for the nested function in the dis.code_info tests

parent f15f8410
...@@ -259,7 +259,7 @@ Stack size: 7 ...@@ -259,7 +259,7 @@ Stack size: 7
Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, GENERATOR Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, GENERATOR
Constants: Constants:
0: None 0: None
1: <code object f at {1}, file "{0}", line {2}> 1: <code object f at (.*), file "{0}", line {1}>
Variable names: Variable names:
0: x 0: x
1: y 1: y
...@@ -276,7 +276,6 @@ Cell variables: ...@@ -276,7 +276,6 @@ Cell variables:
3: y 3: y
4: x 4: x
5: z""".format(__file__, 5: z""".format(__file__,
hex(id(co_tricky_nested_f)),
co_tricky_nested_f.co_firstlineno) co_tricky_nested_f.co_firstlineno)
code_info_tricky_nested_f = """\ code_info_tricky_nested_f = """\
...@@ -356,14 +355,14 @@ class CodeInfoTests(unittest.TestCase): ...@@ -356,14 +355,14 @@ class CodeInfoTests(unittest.TestCase):
def test_code_info(self): def test_code_info(self):
self.maxDiff = 1000 self.maxDiff = 1000
for x, expected in self.test_pairs: for x, expected in self.test_pairs:
self.assertEqual(dis.code_info(x), expected) self.assertRegexpMatches(dis.code_info(x), expected)
def test_show_code(self): def test_show_code(self):
self.maxDiff = 1000 self.maxDiff = 1000
for x, expected in self.test_pairs: for x, expected in self.test_pairs:
with captured_stdout() as output: with captured_stdout() as output:
dis.show_code(x) dis.show_code(x)
self.assertEqual(output.getvalue(), expected+"\n") self.assertRegexpMatches(output.getvalue(), expected+"\n")
def test_main(): def test_main():
run_unittest(DisTests, CodeInfoTests) run_unittest(DisTests, CodeInfoTests)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment