]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-110923: Fix silently skipped tests in test__opcode.py (#110926)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Mon, 16 Oct 2023 13:30:35 +0000 (14:30 +0100)
committerGitHub <noreply@github.com>
Mon, 16 Oct 2023 13:30:35 +0000 (13:30 +0000)
Lib/test/.ruff.toml
Lib/test/test__opcode.py

index 329a3b4fba6b5beb1b1466908ad525ccd7cdf0a8..ed108550fbf6cc01ccc25daa7d02d2628a432387 100644 (file)
@@ -11,7 +11,6 @@ extend-exclude = [
     "encoded_modules/module_iso_8859_1.py",
     "encoded_modules/module_koi8_r.py",
     # TODO Fix: F811 Redefinition of unused name
-    "test__opcode.py",
     "test_buffer.py",
     "test_ctypes/test_arrays.py",
     "test_ctypes/test_functions.py",
index c1f612dc4a63cb6484816448f5458cf4b57cf4cb..10f04b64dda40ec48f389ef64f2053822f701cd2 100644 (file)
@@ -8,6 +8,14 @@ from _opcode import stack_effect
 
 
 class OpListTests(unittest.TestCase):
+    def check_bool_function_result(self, func, ops, expected):
+        for op in ops:
+            if isinstance(op, str):
+                op = dis.opmap[op]
+            with self.subTest(opcode=op, func=func):
+                self.assertIsInstance(func(op), bool)
+                self.assertEqual(func(op), expected)
+
     def test_invalid_opcodes(self):
         invalid = [-100, -1, 255, 512, 513, 1000]
         self.check_bool_function_result(_opcode.is_valid, invalid, False)
@@ -47,7 +55,7 @@ class OpListTests(unittest.TestCase):
         check_function(self, _opcode.has_exc, dis.hasexc)
 
 
-class OpListTests(unittest.TestCase):
+class StackEffectTests(unittest.TestCase):
     def test_stack_effect(self):
         self.assertEqual(stack_effect(dis.opmap['POP_TOP']), -1)
         self.assertEqual(stack_effect(dis.opmap['BUILD_SLICE'], 0), -1)