[Python-checkins] gh-106368: Argument Clinic: Add tests for cloned functions with custom C base names (#107977)

erlend-aasland webhook-mailer at python.org
Tue Aug 15 16:55:53 EDT 2023


https://github.com/python/cpython/commit/bb456a08a3db851e6feaefc3328f39096919ec8d
commit: bb456a08a3db851e6feaefc3328f39096919ec8d
branch: main
author: Erlend E. Aasland <erlend at python.org>
committer: erlend-aasland <erlend.aasland at protonmail.com>
date: 2023-08-15T14:45:53-06:00
summary:

gh-106368: Argument Clinic: Add tests for cloned functions with custom C base names (#107977)

files:
M Lib/test/test_clinic.py

diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 896730571d815..76729c8c3e4f7 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -653,6 +653,37 @@ def test_no_c_basename_cloned(self):
         err = "No C basename provided after 'as' keyword"
         self.expect_failure(block, err, lineno=5)
 
+    def test_cloned_with_custom_c_basename(self):
+        raw = dedent("""
+            /*[clinic input]
+            # Make sure we don't create spurious clinic/ directories.
+            output everything suppress
+            foo2
+            [clinic start generated code]*/
+
+            /*[clinic input]
+            foo as foo1 = foo2
+            [clinic start generated code]*/
+        """)
+        self.clinic.parse(raw)
+        funcs = self.clinic.functions
+        self.assertEqual(len(funcs), 2)
+        self.assertEqual(funcs[1].name, "foo")
+        self.assertEqual(funcs[1].c_basename, "foo1")
+
+    def test_cloned_with_illegal_c_basename(self):
+        block = """
+            /*[clinic input]
+            class C "void *" ""
+            foo1
+            [clinic start generated code]*/
+
+            /*[clinic input]
+            foo2 as .illegal. = foo1
+            [clinic start generated code]*/
+        """
+        err = "Illegal C basename: '.illegal. = foo1'"
+        self.expect_failure(block, err, lineno=7)
 
 
 class ParseFileUnitTest(TestCase):



More information about the Python-checkins mailing list