13
13
import os .path
14
14
import re
15
15
import sys
16
- import types
17
16
import unittest
18
17
19
18
test_tools .skip_if_missing ('clinic' )
22
21
from clinic import DSLParser
23
22
24
23
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
-
32
24
def _make_clinic (* , filename = 'clinic_tests' ):
33
25
clang = clinic .CLanguage (None )
34
- c = clinic .Clinic (clang , filename = filename )
26
+ c = clinic .Clinic (clang , filename = filename , limited_capi = False )
35
27
c .block_parser = clinic .BlockParser ('' , clang )
36
28
return c
37
29
@@ -60,11 +52,6 @@ def _expect_failure(tc, parser, code, errmsg, *, filename=None, lineno=None,
60
52
return cm .exception
61
53
62
54
63
- class MockClinic :
64
- def __init__ (self ):
65
- self .limited_capi = clinic .DEFAULT_LIMITED_CAPI
66
-
67
-
68
55
class ClinicWholeFileTest (TestCase ):
69
56
maxDiff = None
70
57
@@ -138,7 +125,7 @@ def test_parse_with_body_prefix(self):
138
125
clang .body_prefix = "//"
139
126
clang .start_line = "//[{dsl_name} start]"
140
127
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 )
142
129
raw = dedent ("""
143
130
//[clinic start]
144
131
//module test
@@ -704,9 +691,8 @@ def expect_parsing_failure(
704
691
self , * , filename , expected_error , verify = True , output = None
705
692
):
706
693
errmsg = re .escape (dedent (expected_error ).strip ())
707
- ns = default_namespace ()
708
694
with self .assertRaisesRegex (clinic .ClinicError , errmsg ):
709
- clinic .parse_file (filename , ns = ns )
695
+ clinic .parse_file (filename , limited_capi = False )
710
696
711
697
def test_parse_file_no_extension (self ) -> None :
712
698
self .expect_parsing_failure (
@@ -846,9 +832,9 @@ def _test(self, input, output):
846
832
847
833
blocks = list (clinic .BlockParser (input , language ))
848
834
writer = clinic .BlockPrinter (language )
849
- mock_clinic = MockClinic ()
835
+ c = _make_clinic ()
850
836
for block in blocks :
851
- writer .print_block (block , clinic = mock_clinic )
837
+ writer .print_block (block , clinic = c )
852
838
output = writer .f .getvalue ()
853
839
assert output == input , "output != input!\n \n output " + repr (output ) + "\n \n input " + repr (input )
854
840
@@ -874,7 +860,7 @@ def test_round_trip_2(self):
874
860
875
861
def _test_clinic (self , input , output ):
876
862
language = clinic .CLanguage (None )
877
- c = clinic .Clinic (language , filename = "file" )
863
+ c = clinic .Clinic (language , filename = "file" , limited_capi = False )
878
864
c .parsers ['inert' ] = InertParser (c )
879
865
c .parsers ['copy' ] = CopyParser (c )
880
866
computed = c .parse (input )
0 commit comments