我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用dis.show_code()。
def test_show_code(self): self.maxDiff = 1000 for x, expected in self.test_pairs: with captured_stdout() as output: dis.show_code(x) self.assertRegex(output.getvalue(), expected+"\n")
def test_show_code(self): self.maxDiff = 1000 for x, expected in self.test_pairs: with captured_stdout() as output: dis.show_code(x) self.assertRegex(output.getvalue(), expected+"\n") output = io.StringIO() dis.show_code(x, file=output) self.assertRegex(output.getvalue(), expected)