diff options
author | Max Bernstein <tekknolagi@users.noreply.github.com> | 2020-12-18 00:30:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 00:30:29 (GMT) |
commit | 6e799be0a18d0bb5bbbdc77cd3c30a229d31dfb4 (patch) | |
tree | 8b341e9f638bbb94f5ffd1ab8d721bdfbe6c5329 /Lib/test/test_dis.py | |
parent | 074ad5123f18923bdb5fa0b6e4bf24de45e32ba9 (diff) | |
download | cpython-6e799be0a18d0bb5bbbdc77cd3c30a229d31dfb4.zip cpython-6e799be0a18d0bb5bbbdc77cd3c30a229d31dfb4.tar.gz cpython-6e799be0a18d0bb5bbbdc77cd3c30a229d31dfb4.tar.bz2 |
bpo-42199: Fix bytecode_helper assertNotInBytecode (#23031)
* bpo-42199: Fix bytecode_helper assertNotInBytecode
Add tests.
* 📜🤖 Added by blurb_it.
Co-authored-by: Dino Viehland <dinoviehland@fb.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_dis.py')
-rw-r--r-- | Lib/test/test_dis.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 7867449..d5d815d 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1212,5 +1212,24 @@ class BytecodeTests(unittest.TestCase): b = dis.Bytecode.from_traceback(tb) self.assertEqual(b.dis(), dis_traceback) + +class TestBytecodeTestCase(BytecodeTestCase): + def test_assert_not_in_with_op_not_in_bytecode(self): + code = compile("a = 1", "<string>", "exec") + self.assertInBytecode(code, "LOAD_CONST", 1) + self.assertNotInBytecode(code, "LOAD_NAME") + self.assertNotInBytecode(code, "LOAD_NAME", "a") + + def test_assert_not_in_with_arg_not_in_bytecode(self): + code = compile("a = 1", "<string>", "exec") + self.assertInBytecode(code, "LOAD_CONST") + self.assertInBytecode(code, "LOAD_CONST", 1) + self.assertNotInBytecode(code, "LOAD_CONST", 2) + + def test_assert_not_in_with_arg_in_bytecode(self): + code = compile("a = 1", "<string>", "exec") + with self.assertRaises(AssertionError): + self.assertNotInBytecode(code, "LOAD_CONST", 1) + if __name__ == "__main__": unittest.main() |