1313import os .path
1414import re
1515import sys
16- import types
1716import unittest
1817
1918test_tools .skip_if_missing ('clinic' )
2221 from clinic import DSLParser
2322
2423
25- def default_namespace ():
26- ns = types .SimpleNamespace ()
27- ns .force = False
28- ns .limited_capi = clinic .DEFAULT_LIMITED_CAPI
29- return ns
30-
31-
3224def _make_clinic (* , filename = 'clinic_tests' ):
3325 clang = clinic .CLanguage (None )
34- c = clinic .Clinic (clang , filename = filename )
26+ c = clinic .Clinic (clang , filename = filename , limited_capi = False )
3527 c .block_parser = clinic .BlockParser ('' , clang )
3628 return c
3729
@@ -60,11 +52,6 @@ def _expect_failure(tc, parser, code, errmsg, *, filename=None, lineno=None,
6052 return cm .exception
6153
6254
63- class MockClinic :
64- def __init__ (self ):
65- self .limited_capi = clinic .DEFAULT_LIMITED_CAPI
66-
67-
6855class ClinicWholeFileTest (TestCase ):
6956 maxDiff = None
7057
@@ -138,7 +125,7 @@ def test_parse_with_body_prefix(self):
138125 clang .body_prefix = "//"
139126 clang .start_line = "//[{dsl_name} start]"
140127 clang .stop_line = "//[{dsl_name} stop]"
141- cl = clinic .Clinic (clang , filename = "test.c" )
128+ cl = clinic .Clinic (clang , filename = "test.c" , limited_capi = False )
142129 raw = dedent ("""
143130 //[clinic start]
144131 //module test
@@ -704,9 +691,8 @@ def expect_parsing_failure(
704691 self , * , filename , expected_error , verify = True , output = None
705692 ):
706693 errmsg = re .escape (dedent (expected_error ).strip ())
707- ns = default_namespace ()
708694 with self .assertRaisesRegex (clinic .ClinicError , errmsg ):
709- clinic .parse_file (filename , ns = ns )
695+ clinic .parse_file (filename , limited_capi = False )
710696
711697 def test_parse_file_no_extension (self ) -> None :
712698 self .expect_parsing_failure (
@@ -846,9 +832,9 @@ def _test(self, input, output):
846832
847833 blocks = list (clinic .BlockParser (input , language ))
848834 writer = clinic .BlockPrinter (language )
849- mock_clinic = MockClinic ()
835+ c = _make_clinic ()
850836 for block in blocks :
851- writer .print_block (block , clinic = mock_clinic )
837+ writer .print_block (block , clinic = c )
852838 output = writer .f .getvalue ()
853839 assert output == input , "output != input!\n \n output " + repr (output ) + "\n \n input " + repr (input )
854840
@@ -874,7 +860,7 @@ def test_round_trip_2(self):
874860
875861 def _test_clinic (self , input , output ):
876862 language = clinic .CLanguage (None )
877- c = clinic .Clinic (language , filename = "file" )
863+ c = clinic .Clinic (language , filename = "file" , limited_capi = False )
878864 c .parsers ['inert' ] = InertParser (c )
879865 c .parsers ['copy' ] = CopyParser (c )
880866 computed = c .parse (input )
0 commit comments