99import sys
1010
1111from waiter import Waiter , LazySubprocess
12+ from mypy .test .testsamples import find_files , file_to_module
1213
1314
1415def get_versions () -> List [str ]:
@@ -106,20 +107,6 @@ def list_tasks(self) -> None:
106107 print ('{id}:{task}' .format (id = id , task = task .name ))
107108
108109
109- def find_files (base : str , prefix : str = '' , suffix : str = '' ) -> List [str ]:
110- return [join (root , f )
111- for root , dirs , files in os .walk (base )
112- for f in files
113- if f .startswith (prefix ) and f .endswith (suffix )]
114-
115-
116- def file_to_module (file : str ) -> str :
117- rv = os .path .splitext (file )[0 ].replace (os .sep , '.' )
118- if rv .endswith ('.__init__' ):
119- rv = rv [:- len ('.__init__' )]
120- return rv
121-
122-
123110def test_path (* names : str ) -> List [str ]:
124111 return [os .path .join ('mypy' , 'test' , '{}.py' .format (name ))
125112 for name in names ]
@@ -155,6 +142,7 @@ def test_path(*names: str) -> List[str]:
155142 'testpythoneval' ,
156143 'testcmdline' ,
157144 'teststubgen' ,
145+ 'testsamples' ,
158146)
159147
160148SELFCHECK_FILES = test_path (
@@ -170,23 +158,6 @@ def add_pytest(driver: Driver) -> None:
170158 [('self-check' , name ) for name in SELFCHECK_FILES ])
171159
172160
173- def add_stubs (driver : Driver ) -> None :
174- # We only test each module in the one version mypy prefers to find.
175- # TODO: test stubs for other versions, especially Python 2 stubs.
176-
177- modules = {'typing' }
178- # TODO: This should also test Python 2, and pass pyversion accordingly.
179- for version in ["2and3" , "3" , "3.5" ]:
180- for stub_type in ['builtins' , 'stdlib' , 'third_party' ]:
181- stubdir = join ('typeshed' , stub_type , version )
182- for f in find_files (stubdir , suffix = '.pyi' ):
183- module = file_to_module (f [len (stubdir ) + 1 :])
184- modules .add (module )
185-
186- # these require at least 3.5 otherwise it will fail trying to import zipapp
187- driver .add_mypy_modules ('stubs' , sorted (modules ), extra_args = ['--python-version=3.5' ])
188-
189-
190161def add_stdlibsamples (driver : Driver ) -> None :
191162 seen = set () # type: Set[str]
192163 stdlibsamples_dir = join (driver .cwd , 'test-data' , 'stdlib-samples' , '3.2' , 'test' )
@@ -202,15 +173,6 @@ def add_stdlibsamples(driver: Driver) -> None:
202173 cwd = stdlibsamples_dir , extra_args = ['--no-strict-optional' ])
203174
204175
205- def add_samples (driver : Driver ) -> None :
206- for f in find_files (os .path .join ('test-data' , 'samples' ), suffix = '.py' ):
207- mypy_args = ['--no-strict-optional' ]
208- if f == os .path .join ('test-data' , 'samples' , 'crawl2.py' ):
209- # This test requires 3.5 for async functions
210- mypy_args .append ('--python-version=3.5' )
211- driver .add_mypy_cmd ('file {}' .format (f ), mypy_args + [f ])
212-
213-
214176def usage (status : int ) -> None :
215177 print ('Usage: %s [-h | -v | -q | --lf | --ff | [-x] FILTER | -a ARG | -p ARG]'
216178 '... [-- FILTER ...]'
@@ -348,9 +310,7 @@ def main() -> None:
348310
349311 driver .add_flake8 ()
350312 add_pytest (driver )
351- add_stubs (driver )
352313 add_stdlibsamples (driver )
353- add_samples (driver )
354314
355315 if list_only :
356316 driver .list_tasks ()
0 commit comments