summaryrefslogtreecommitdiffstats
path: root/Lib/test/bytecode_helper.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2013-11-06 12:08:36 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2013-11-06 12:08:36 (GMT)
commit90b8e7d2bc20a6b63042ca9ba5024ea8bb45d168 (patch)
tree6c2a688294bf44a91c1401f1e17e708af40ea6c7 /Lib/test/bytecode_helper.py
parente0881f464cea34b263efe45afb92b5919a639468 (diff)
downloadcpython-90b8e7d2bc20a6b63042ca9ba5024ea8bb45d168.zip
cpython-90b8e7d2bc20a6b63042ca9ba5024ea8bb45d168.tar.gz
cpython-90b8e7d2bc20a6b63042ca9ba5024ea8bb45d168.tar.bz2
Close #19378: address flaws in the new dis module APIs
- confusing line_offset parameter -> first_line parameter - systematically test and fix new file parameter - remove redundant Bytecode.show_info() API - rename Bytecode.display_code() to Bytecode.dis() and have it return the multi-line string rather than printing it directly - eliminated some not-so-helpful helpers from the bytecode_helper test support module Also fixed a longstanding defect (worked around in the test suite) where lines emitted by the dis module could include trailing white space. That no longer happens, allowing the formatting tests to be simplified to use plain string comparisons.
Diffstat (limited to 'Lib/test/bytecode_helper.py')
-rw-r--r--Lib/test/bytecode_helper.py31
1 files changed, 0 insertions, 31 deletions
diff --git a/Lib/test/bytecode_helper.py b/Lib/test/bytecode_helper.py
index c4943cd..58b4209 100644
--- a/Lib/test/bytecode_helper.py
+++ b/Lib/test/bytecode_helper.py
@@ -14,37 +14,6 @@ class BytecodeTestCase(unittest.TestCase):
dis.dis(co, file=s)
return s.getvalue()
- def assertInstructionMatches(self, instr, expected, *, line_offset=0):
- # Deliberately test opname first, since that gives a more
- # meaningful error message than testing opcode
- self.assertEqual(instr.opname, expected.opname)
- self.assertEqual(instr.opcode, expected.opcode)
- self.assertEqual(instr.arg, expected.arg)
- self.assertEqual(instr.argval, expected.argval)
- self.assertEqual(instr.argrepr, expected.argrepr)
- self.assertEqual(instr.offset, expected.offset)
- if expected.starts_line is None:
- self.assertIsNone(instr.starts_line)
- else:
- self.assertEqual(instr.starts_line,
- expected.starts_line + line_offset)
- self.assertEqual(instr.is_jump_target, expected.is_jump_target)
-
-
- def assertBytecodeExactlyMatches(self, x, expected, *, line_offset=0):
- """Throws AssertionError if any discrepancy is found in bytecode
-
- *x* is the object to be introspected
- *expected* is a list of dis.Instruction objects
-
- Set *line_offset* as appropriate to adjust for the location of the
- object to be disassembled within the test file. If the expected list
- assumes the first line is line 1, then an appropriate offset would be
- ``1 - f.__code__.co_firstlineno``.
- """
- actual = dis.get_instructions(x, line_offset=line_offset)
- self.assertEqual(list(actual), expected)
-
def assertInBytecode(self, x, opname, argval=_UNSPECIFIED):
"""Returns instr if op is found, otherwise throws AssertionError"""
for instr in dis.get_instructions(x):