(pytester: Pytester)
| 1697 | |
| 1698 | |
| 1699 | def test_is_importable(pytester: Pytester) -> None: |
| 1700 | pytester.syspathinsert() |
| 1701 | |
| 1702 | path = pytester.path / "bar/foo.py" |
| 1703 | path.parent.mkdir() |
| 1704 | path.touch() |
| 1705 | assert is_importable("bar.foo", path) is True |
| 1706 | |
| 1707 | # Ensure that the module that can be imported points to the path we expect. |
| 1708 | path = pytester.path / "some/other/path/bar/foo.py" |
| 1709 | path.mkdir(parents=True, exist_ok=True) |
| 1710 | assert is_importable("bar.foo", path) is False |
| 1711 | |
| 1712 | # Paths containing "." cannot be imported. |
| 1713 | path = pytester.path / "bar.x/__init__.py" |
| 1714 | path.parent.mkdir() |
| 1715 | path.touch() |
| 1716 | assert is_importable("bar.x", path) is False |
| 1717 | |
| 1718 | # Pass starting with "." denote relative imports and cannot be checked using is_importable. |
| 1719 | path = pytester.path / ".bar.x/__init__.py" |
| 1720 | path.parent.mkdir() |
| 1721 | path.touch() |
| 1722 | assert is_importable(".bar.x", path) is False |
| 1723 | |
| 1724 | |
| 1725 | def test_compute_module_name(tmp_path: Path) -> None: |
nothing calls this directly
no test coverage detected