Skip to content
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

gh-113317: Clean up Argument Clinic global namespace #113414

Merged
merged 10 commits into from
Dec 23, 2023
29 changes: 15 additions & 14 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

test_tools.skip_if_missing('clinic')
with test_tools.imports_under_tool('clinic'):
import libclinic
import clinic
from clinic import DSLParser

Expand Down Expand Up @@ -3761,19 +3762,19 @@ def test_normalize_snippet(self):
actual = clinic.normalize_snippet(snippet, indent=indent)
self.assertEqual(actual, expected)

def test_quoted_for_c_string(self):
def test_escaped_docstring(self):
dataset = (
# input, expected
(r"abc", r"abc"),
(r"\abc", r"\\abc"),
(r"\a\bc", r"\\a\\bc"),
(r"\a\\bc", r"\\a\\\\bc"),
(r'"abc"', r'\"abc\"'),
(r"'a'", r"\'a\'"),
(r"abc", r'"abc"'),
(r"\abc", r'"\\abc"'),
(r"\a\bc", r'"\\a\\bc"'),
(r"\a\\bc", r'"\\a\\\\bc"'),
(r'"abc"', r'"\"abc\""'),
(r"'a'", r'"\'a\'"'),
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved
)
for line, expected in dataset:
with self.subTest(line=line, expected=expected):
out = clinic.quoted_for_c_string(line)
out = libclinic.docstring_for_c_string(line)
self.assertEqual(out, expected)

def test_format_escape(self):
Expand All @@ -3784,7 +3785,7 @@ def test_format_escape(self):

def test_indent_all_lines(self):
# Blank lines are expected to be unchanged.
self.assertEqual(clinic.indent_all_lines("", prefix="bar"), "")
self.assertEqual(libclinic.indent_all_lines("", prefix="bar"), "")

lines = (
"one\n"
Expand All @@ -3794,7 +3795,7 @@ def test_indent_all_lines(self):
"barone\n"
"bartwo"
)
out = clinic.indent_all_lines(lines, prefix="bar")
out = libclinic.indent_all_lines(lines, prefix="bar")
self.assertEqual(out, expected)

# If last line is empty, expect it to be unchanged.
Expand All @@ -3810,12 +3811,12 @@ def test_indent_all_lines(self):
"bartwo\n"
""
)
out = clinic.indent_all_lines(lines, prefix="bar")
out = libclinic.indent_all_lines(lines, prefix="bar")
self.assertEqual(out, expected)

def test_suffix_all_lines(self):
# Blank lines are expected to be unchanged.
self.assertEqual(clinic.suffix_all_lines("", suffix="foo"), "")
self.assertEqual(libclinic.suffix_all_lines("", suffix="foo"), "")

lines = (
"one\n"
Expand All @@ -3825,7 +3826,7 @@ def test_suffix_all_lines(self):
"onefoo\n"
"twofoo"
)
out = clinic.suffix_all_lines(lines, suffix="foo")
out = libclinic.suffix_all_lines(lines, suffix="foo")
self.assertEqual(out, expected)

# If last line is empty, expect it to be unchanged.
Expand All @@ -3841,7 +3842,7 @@ def test_suffix_all_lines(self):
"twofoo\n"
""
)
out = clinic.suffix_all_lines(lines, suffix="foo")
out = libclinic.suffix_all_lines(lines, suffix="foo")
self.assertEqual(out, expected)


Expand Down
Loading
Loading