Skip to content

Commit

Permalink
pythongh-106368: Argument Clinic: Add tests for cloned functions with…
Browse files Browse the repository at this point in the history
… custom C base names (python#107977)
  • Loading branch information
erlend-aasland authored Aug 15, 2023
1 parent 99b6ce5 commit bb456a0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit bb456a0

Please sign in to comment.