Skip to content

gh-106368: Increase coverage for Argument Clinic output directive #106979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-106368: Increase coverage for Argument Clinic output directive
  • Loading branch information
erlend-aasland committed Jul 21, 2023
commit c95cd19a92ed023d70cb88e05ed082dbd83f7b22
53 changes: 53 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,59 @@ def test_cpp_monitor_fail_no_matching_if(self):
out = self.expect_failure(raw)
self.assertEqual(out, msg)

def test_directive_output_unknown_preset(self):
out = self.expect_failure("""
/*[clinic input]
output preset nosuchpreset
[clinic start generated code]*/
""")
msg = "Unknown preset 'nosuchpreset'"
self.assertIn(msg, out)

def test_directive_output_cant_pop(self):
out = self.expect_failure("""
/*[clinic input]
output pop
[clinic start generated code]*/
""")
msg = "Can't 'output pop', stack is empty"
self.assertIn(msg, out)

def test_directive_output_print(self):
raw = dedent("""
/*[clinic input]
output print 'I told you once.'
[clinic start generated code]*/
""")
out = self.clinic.parse(raw)
# The generated output will differ for every run, but we can check that
# it starts with the clinic block, we check that it contains all the
# expected fields, and we check that it contains the checksum line.
self.assertTrue(out.startswith(dedent("""
/*[clinic input]
output print 'I told you once.'
[clinic start generated code]*/
""")))
fields = {
"cpp_endif",
"cpp_if",
"docstring_definition",
"docstring_prototype",
"impl_definition",
"impl_prototype",
"methoddef_define",
"methoddef_ifndef",
"parser_definition",
"parser_prototype",
}
for field in fields:
with self.subTest(field=field):
self.assertIn(field, out)
last_line = out.rstrip().split("\n")[-1]
self.assertTrue(
last_line.startswith("/*[clinic end generated code: output=")
)


class ClinicGroupPermuterTest(TestCase):
def _test(self, l, m, r, output):
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy