@@ -1376,29 +1376,26 @@ def test_full_ns_packages_without_init_files(
1376
1376
def test_is_importable (pytester : Pytester ) -> None :
1377
1377
pytester .syspathinsert ()
1378
1378
1379
- # Module package.
1380
- path = pytester .path / "is_importable/foo.py"
1379
+ path = pytester .path / "bar/foo.py"
1381
1380
path .parent .mkdir ()
1382
1381
path .touch ()
1383
- assert is_importable ("is_importable.foo" , path ) is True
1384
-
1385
- # Standalone module.
1386
- path = pytester .path / "is_importable_module.py"
1387
- path .touch ()
1388
- assert is_importable ("is_importable_module" , path ) is True
1382
+ assert is_importable ("bar.foo" , path ) is True
1389
1383
1390
1384
# Ensure that the module that can be imported points to the path we expect.
1391
- path = pytester .path / "some/other/path/is_importable_module.py"
1392
- assert is_importable ("is_importable_module" , path ) is False
1385
+ path = pytester .path / "some/other/path/bar/foo.py"
1386
+ path .mkdir (parents = True , exist_ok = True )
1387
+ assert is_importable ("bar.foo" , path ) is False
1393
1388
1394
1389
# Paths containing "." cannot be imported.
1395
- path = pytester .path / "bar.x"
1396
- path .mkdir ()
1390
+ path = pytester .path / "bar.x/__init__.py"
1391
+ path .parent .mkdir ()
1392
+ path .touch ()
1397
1393
assert is_importable ("bar.x" , path ) is False
1398
1394
1399
1395
# Pass starting with "." denote relative imports and cannot be checked using is_importable.
1400
- path = pytester .path / ".bar.x"
1401
- path .mkdir ()
1396
+ path = pytester .path / ".bar.x/__init__.py"
1397
+ path .parent .mkdir ()
1398
+ path .touch ()
1402
1399
assert is_importable (".bar.x" , path ) is False
1403
1400
1404
1401
0 commit comments