1
1
import os
2
2
import tempfile
3
3
from unittest import TestCase , main
4
- from mypy . options import Options
4
+
5
5
from mypy .config_parser import parse_config_file
6
+ from mypy .options import Options
7
+
6
8
7
9
class TestConfigParser (TestCase ):
8
10
def test_parse_config_file_with_single_file (self ):
@@ -20,13 +22,7 @@ def test_parse_config_file_with_single_file(self):
20
22
21
23
options = Options ()
22
24
23
- parse_config_file (
24
- options ,
25
- lambda : None ,
26
- config_path ,
27
- stdout = None ,
28
- stderr = None ,
29
- )
25
+ parse_config_file (options , lambda : None , config_path , stdout = None , stderr = None )
30
26
31
27
self .assertEqual (options .files , ["file1.py" ])
32
28
@@ -45,13 +41,7 @@ def test_parse_config_file_with_no_spaces(self):
45
41
46
42
options = Options ()
47
43
48
- parse_config_file (
49
- options ,
50
- lambda : None ,
51
- config_path ,
52
- stdout = None ,
53
- stderr = None ,
54
- )
44
+ parse_config_file (options , lambda : None , config_path , stdout = None , stderr = None )
55
45
56
46
self .assertEqual (options .files , ["file1.py" , "file2.py" , "file3.py" ])
57
47
@@ -64,19 +54,13 @@ def test_parse_config_file_with_extra_spaces(self):
64
54
f .write (
65
55
"""
66
56
[mypy]
67
- files = file1.py , file2.py , file3.py
57
+ files = file1.py , file2.py , file3.py
68
58
"""
69
59
)
70
60
71
61
options = Options ()
72
62
73
- parse_config_file (
74
- options ,
75
- lambda : None ,
76
- config_path ,
77
- stdout = None ,
78
- stderr = None ,
79
- )
63
+ parse_config_file (options , lambda : None , config_path , stdout = None , stderr = None )
80
64
81
65
self .assertEqual (options .files , ["file1.py" , "file2.py" , "file3.py" ])
82
66
@@ -89,19 +73,13 @@ def test_parse_config_file_with_empty_files_key(self):
89
73
f .write (
90
74
"""
91
75
[mypy]
92
- files =
76
+ files =
93
77
"""
94
78
)
95
79
96
80
options = Options ()
97
81
98
- parse_config_file (
99
- options ,
100
- lambda : None ,
101
- config_path ,
102
- stdout = None ,
103
- stderr = None ,
104
- )
82
+ parse_config_file (options , lambda : None , config_path , stdout = None , stderr = None )
105
83
106
84
self .assertEqual (options .files , [])
107
85
@@ -121,13 +99,7 @@ def test_parse_config_file_with_only_comma(self):
121
99
options = Options ()
122
100
123
101
with self .assertRaises (ValueError ) as cm :
124
- parse_config_file (
125
- options ,
126
- lambda : None ,
127
- config_path ,
128
- stdout = None ,
129
- stderr = None ,
130
- )
102
+ parse_config_file (options , lambda : None , config_path , stdout = None , stderr = None )
131
103
132
104
self .assertIn ("Invalid config" , str (cm .exception ))
133
105
@@ -140,19 +112,13 @@ def test_parse_config_file_with_only_whitespace(self):
140
112
f .write (
141
113
"""
142
114
[mypy]
143
- files =
115
+ files =
144
116
"""
145
117
)
146
118
147
119
options = Options ()
148
120
149
- parse_config_file (
150
- options ,
151
- lambda : None ,
152
- config_path ,
153
- stdout = None ,
154
- stderr = None ,
155
- )
121
+ parse_config_file (options , lambda : None , config_path , stdout = None , stderr = None )
156
122
157
123
self .assertEqual (options .files , [])
158
124
@@ -172,13 +138,7 @@ def test_parse_config_file_with_mixed_valid_and_invalid_entries(self):
172
138
options = Options ()
173
139
174
140
with self .assertRaises (ValueError ) as cm :
175
- parse_config_file (
176
- options ,
177
- lambda : None ,
178
- config_path ,
179
- stdout = None ,
180
- stderr = None ,
181
- )
141
+ parse_config_file (options , lambda : None , config_path , stdout = None , stderr = None )
182
142
183
143
self .assertIn ("Invalid config" , str (cm .exception ))
184
144
@@ -199,15 +159,10 @@ def test_parse_config_file_with_newlines_between_files(self):
199
159
200
160
options = Options ()
201
161
202
- parse_config_file (
203
- options ,
204
- lambda : None ,
205
- config_path ,
206
- stdout = None ,
207
- stderr = None ,
208
- )
162
+ parse_config_file (options , lambda : None , config_path , stdout = None , stderr = None )
209
163
210
164
self .assertEqual (options .files , ["file1.py" , "file2.py" , "file3.py" ])
211
165
166
+
212
167
if __name__ == "__main__" :
213
168
main ()
0 commit comments