Skip to content

Commit c43f6a4

Browse files
authored
gh-113317: Argument Clinic: Add libclinic.clanguage (#117455)
Add libclinic.clanguage module and move the following classes and functions there: * CLanguage * declare_parser() Add libclinic.codegen and move the following classes there: * BlockPrinter * BufferSeries * Destination Move the following functions to libclinic.function: * permute_left_option_groups() * permute_optional_groups() * permute_right_option_groups()
1 parent 1c43468 commit c43f6a4

File tree

5 files changed

+1635
-1602
lines changed

5 files changed

+1635
-1602
lines changed

Lib/test/test_clinic.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
with test_tools.imports_under_tool('clinic'):
1919
import libclinic
2020
from libclinic.converters import int_converter, str_converter
21+
from libclinic.function import (
22+
permute_optional_groups, permute_right_option_groups,
23+
permute_left_option_groups)
2124
import clinic
2225
from clinic import DSLParser
2326

@@ -679,7 +682,7 @@ def test_parse_file_strange_extension(self) -> None:
679682

680683
class ClinicGroupPermuterTest(TestCase):
681684
def _test(self, l, m, r, output):
682-
computed = clinic.permute_optional_groups(l, m, r)
685+
computed = permute_optional_groups(l, m, r)
683686
self.assertEqual(output, computed)
684687

685688
def test_range(self):
@@ -721,7 +724,7 @@ def test_right_only(self):
721724

722725
def test_have_left_options_but_required_is_empty(self):
723726
def fn():
724-
clinic.permute_optional_groups(['a'], [], [])
727+
permute_optional_groups(['a'], [], [])
725728
self.assertRaises(ValueError, fn)
726729

727730

@@ -3764,7 +3767,7 @@ def test_permute_left_option_groups(self):
37643767
(1, 2, 3),
37653768
)
37663769
data = list(zip([1, 2, 3])) # Generate a list of 1-tuples.
3767-
actual = tuple(clinic.permute_left_option_groups(data))
3770+
actual = tuple(permute_left_option_groups(data))
37683771
self.assertEqual(actual, expected)
37693772

37703773
def test_permute_right_option_groups(self):
@@ -3775,7 +3778,7 @@ def test_permute_right_option_groups(self):
37753778
(1, 2, 3),
37763779
)
37773780
data = list(zip([1, 2, 3])) # Generate a list of 1-tuples.
3778-
actual = tuple(clinic.permute_right_option_groups(data))
3781+
actual = tuple(permute_right_option_groups(data))
37793782
self.assertEqual(actual, expected)
37803783

37813784
def test_permute_optional_groups(self):
@@ -3854,7 +3857,7 @@ def test_permute_optional_groups(self):
38543857
for params in dataset:
38553858
with self.subTest(**params):
38563859
left, required, right, expected = params.values()
3857-
permutations = clinic.permute_optional_groups(left, required, right)
3860+
permutations = permute_optional_groups(left, required, right)
38583861
actual = tuple(permutations)
38593862
self.assertEqual(actual, expected)
38603863

0 commit comments

Comments
 (0)