summaryrefslogtreecommitdiff
path: root/tests/basics/fun_code_lnotab.py
diff options
context:
space:
mode:
authorAnson Mansfield <amansfield@mantaro.com>2025-07-08 10:54:00 -0400
committerAnson Mansfield <amansfield@mantaro.com>2025-07-18 10:59:21 -0400
commit7b38fa4fa3a1c44d224492b1f75a7a9f125c6d18 (patch)
treeb972f451969e52c02845bdf2b3bc792e87c57a2e /tests/basics/fun_code_lnotab.py
parent17fbc5abdc7e139a922f6a11619deb7cb031e0cb (diff)
tests/basics/fun_code_lnotab: Test removal of co_lnotab from v2.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Diffstat (limited to 'tests/basics/fun_code_lnotab.py')
-rw-r--r--tests/basics/fun_code_lnotab.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/basics/fun_code_lnotab.py b/tests/basics/fun_code_lnotab.py
new file mode 100644
index 000000000..9223e5730
--- /dev/null
+++ b/tests/basics/fun_code_lnotab.py
@@ -0,0 +1,34 @@
+# Test deprecation of co_lnotab
+
+try:
+ (lambda: 0).__code__.co_code
+except AttributeError:
+ print("SKIP")
+ raise SystemExit
+
+
+import unittest
+import sys
+
+
+mpy_is_v2 = getattr(sys.implementation, '_v2', False)
+
+
+def f():
+ pass
+
+
+class Test(unittest.TestCase):
+
+ @unittest.skipIf(mpy_is_v2, "Removed in MicroPython v2 and later.")
+ def test_co_lnotab_exists(self):
+ self.assertIsInstance(f.__code__.co_lnotab, bytes)
+
+ @unittest.skipUnless(mpy_is_v2, "Not removed before MicroPython v2.")
+ def test_co_lnotab_removed(self):
+ with self.assertRaises(AttributeError):
+ f.__code__.co_lnotab
+
+
+if __name__ == "__main__":
+ unittest.main()