MCPcopy Index your code
hub / github.com/python/cpython / assertOpcodeSourcePositionIs

Method assertOpcodeSourcePositionIs

Lib/test/test_compile.py:1933–1948  ·  view source on GitHub ↗
(self, code, opcode,
            line, end_line, column, end_column, occurrence=1)

Source from the content-addressed store, hash-verified

1931 return code, ast_tree
1932
1933 def assertOpcodeSourcePositionIs(self, code, opcode,
1934 line, end_line, column, end_column, occurrence=1):
1935
1936 for instr, position in instructions_with_positions(
1937 dis.Bytecode(code), code.co_positions()
1938 ):
1939 if instr.opname == opcode:
1940 occurrence -= 1
1941 if not occurrence:
1942 self.assertEqual(position[0], line)
1943 self.assertEqual(position[1], end_line)
1944 self.assertEqual(position[2], column)
1945 self.assertEqual(position[3], end_column)
1946 return
1947
1948 self.fail(f"Opcode {opcode} not found in code")
1949
1950 def test_simple_assignment(self):
1951 snippet = "x = 1"

Calls 3

assertEqualMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected