Skip to content

Commit bb456a0

Browse files
gh-106368: Argument Clinic: Add tests for cloned functions with custom C base names (#107977)
1 parent 99b6ce5 commit bb456a0

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Lib/test/test_clinic.py

+31
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,37 @@ def test_no_c_basename_cloned(self):
653653
err = "No C basename provided after 'as' keyword"
654654
self.expect_failure(block, err, lineno=5)
655655

656+
def test_cloned_with_custom_c_basename(self):
657+
raw = dedent("""
658+
/*[clinic input]
659+
# Make sure we don't create spurious clinic/ directories.
660+
output everything suppress
661+
foo2
662+
[clinic start generated code]*/
663+
664+
/*[clinic input]
665+
foo as foo1 = foo2
666+
[clinic start generated code]*/
667+
""")
668+
self.clinic.parse(raw)
669+
funcs = self.clinic.functions
670+
self.assertEqual(len(funcs), 2)
671+
self.assertEqual(funcs[1].name, "foo")
672+
self.assertEqual(funcs[1].c_basename, "foo1")
673+
674+
def test_cloned_with_illegal_c_basename(self):
675+
block = """
676+
/*[clinic input]
677+
class C "void *" ""
678+
foo1
679+
[clinic start generated code]*/
680+
681+
/*[clinic input]
682+
foo2 as .illegal. = foo1
683+
[clinic start generated code]*/
684+
"""
685+
err = "Illegal C basename: '.illegal. = foo1'"
686+
self.expect_failure(block, err, lineno=7)
656687

657688

658689
class ParseFileUnitTest(TestCase):

0 commit comments

Comments
 (0)