summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_clinic.py
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend@python.org>2023-12-23 00:37:39 (GMT)
committerGitHub <noreply@github.com>2023-12-23 00:37:39 (GMT)
commitc3f92f6a7513340dfe2d82bfcd38eb77453e935d (patch)
tree29a5fb460cf3e7ab7ec39865eb2ac93a474f3bd7 /Lib/test/test_clinic.py
parent9c3ddf31a34295ebcef6dc49b9e0ddd75d0ea9f1 (diff)
downloadcpython-c3f92f6a7513340dfe2d82bfcd38eb77453e935d.zip
cpython-c3f92f6a7513340dfe2d82bfcd38eb77453e935d.tar.gz
cpython-c3f92f6a7513340dfe2d82bfcd38eb77453e935d.tar.bz2
gh-113317: Clean up Argument Clinic global namespace (#113414)
Split up clinic.py by establishing libclinic as a support package for Argument Clinic. Get rid of clinic.py globals by either making them class members, or by putting them into libclinic. - Move INCLUDE_COMMENT_COLUMN to BlockPrinter - Move NO_VARARG to CLanguage - Move formatting helpers to libclinic - Move some constants to libclinic (and annotate them as Final)
Diffstat (limited to 'Lib/test/test_clinic.py')
-rw-r--r--Lib/test/test_clinic.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 199c9fe..cfb84bc 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -16,6 +16,7 @@ import unittest
test_tools.skip_if_missing('clinic')
with test_tools.imports_under_tool('clinic'):
+ import libclinic
import clinic
from clinic import DSLParser
@@ -3761,19 +3762,19 @@ class FormatHelperTests(unittest.TestCase):
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\'"'),
)
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):
@@ -3784,7 +3785,7 @@ class FormatHelperTests(unittest.TestCase):
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"
@@ -3794,7 +3795,7 @@ class FormatHelperTests(unittest.TestCase):
"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.
@@ -3810,12 +3811,12 @@ class FormatHelperTests(unittest.TestCase):
"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"
@@ -3825,7 +3826,7 @@ class FormatHelperTests(unittest.TestCase):
"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.
@@ -3841,7 +3842,7 @@ class FormatHelperTests(unittest.TestCase):
"twofoo\n"
""
)
- out = clinic.suffix_all_lines(lines, suffix="foo")
+ out = libclinic.suffix_all_lines(lines, suffix="foo")
self.assertEqual(out, expected)