@@ -216,6 +216,40 @@ def test_typedpkg(self) -> None:
216
216
venv_dir = venv_dir ,
217
217
)
218
218
219
+ def test_mypy_path_is_respected (self ) -> None :
220
+ packages = 'packages'
221
+ pkg_name = 'a'
222
+ with tempfile .TemporaryDirectory () as temp_dir :
223
+ old_dir = os .getcwd ()
224
+ os .chdir (temp_dir )
225
+ try :
226
+ # Create the pkg for files to go into
227
+ full_pkg_name = os .path .join (temp_dir , packages , pkg_name )
228
+ os .makedirs (full_pkg_name )
229
+
230
+ # Create the empty __init__ file to declare a package
231
+ pkg_init_name = os .path .join (temp_dir , packages , pkg_name , '__init__.py' )
232
+ open (pkg_init_name , 'w' , encoding = 'utf8' ).close ()
233
+
234
+ mypy_config_path = os .path .join (temp_dir , 'mypy.ini' )
235
+ with open (mypy_config_path , 'w' ) as mypy_file :
236
+ mypy_file .write ('[mypy]\n ' )
237
+ mypy_file .write ('mypy_path = ./{}\n ' .format (packages ))
238
+
239
+ with self .virtualenv () as venv :
240
+ venv_dir , python_executable = venv
241
+
242
+ cmd_line_args = []
243
+ if python_executable != sys .executable :
244
+ cmd_line_args .append ('--python-executable={}' .format (python_executable ))
245
+ cmd_line_args .extend (['--config-file' , mypy_config_path ,
246
+ '--package' , pkg_name ])
247
+
248
+ out , err , returncode = mypy .api .run (cmd_line_args )
249
+ assert returncode == 0
250
+ finally :
251
+ os .chdir (old_dir )
252
+
219
253
def test_stub_and_typed_pkg (self ) -> None :
220
254
self .simple_prog .create ()
221
255
with self .virtualenv () as venv :
0 commit comments