Skip to content
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
Prev Previous commit
Next Next commit
Address Nikita's review:
Let expect_failure() dedent and strip input string
  • Loading branch information
erlend-aasland committed Jul 15, 2023
commit c7caf0577dcf93a8b0b605355dad43ff3a9dec95
19 changes: 10 additions & 9 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class ClinicWholeFileTest(_ParserBase):
def setUp(self):
self.clinic = clinic.Clinic(clinic.CLanguage(None), filename="test.c")

def expect_failure(self, _input):
def expect_failure(self, raw):
_input = dedent(raw).strip()
return self.expect_parser_failure(self.clinic.parse, _input)

def test_eol(self):
Expand All @@ -127,11 +128,11 @@ def test_eol(self):
self.assertEqual(end_line, "[clinic]*/")

def test_mangled_marker_line(self):
raw = dedent("""
raw = """
/*[clinic input]
[clinic start generated code]*/
/*[clinic end generated code: foo]*/
""").strip()
"""
msg = (
'Error in file "test.c" on line 3:\n'
"Mangled Argument Clinic marker line: '/*[clinic end generated code: foo]*/'\n"
Expand All @@ -140,11 +141,11 @@ def test_mangled_marker_line(self):
self.assertEqual(out, msg)

def test_checksum_mismatch(self):
raw = dedent("""
raw = """
/*[clinic input]
[clinic start generated code]*/
/*[clinic end generated code: output=0123456789abcdef input=fedcba9876543210]*/
""").strip()
"""
msg = (
'Error in file "test.c" on line 3:\n'
'Checksum mismatch!\n'
Expand All @@ -155,10 +156,10 @@ def test_checksum_mismatch(self):
self.assertIn(msg, out)

def test_garbage_after_stop_line(self):
raw = dedent("""
raw = """
/*[clinic input]
[clinic start generated code]*/foobarfoobar!
""").strip()
"""
msg = (
'Error in file "test.c" on line 2:\n'
"Garbage after stop line: 'foobarfoobar!'\n"
Expand All @@ -167,10 +168,10 @@ def test_garbage_after_stop_line(self):
self.assertEqual(out, msg)

def test_whitespace_before_stop_line(self):
raw = dedent("""
raw = """
/*[clinic input]
[clinic start generated code]*/
""").strip()
"""
msg = (
'Error in file "test.c" on line 2:\n'
"Whitespace is not allowed before the stop line: ' [clinic start generated code]*/'\n"
Expand Down