| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import sys |
| 4 |
from pathlib import Path |
| 5 |
|
| 6 |
from sphinx.ext.autodoc._dynamic._importer import _import_module |
| 7 |
|
| 8 |
|
| 9 |
def test_import_native_module_stubs(rootdir: Path) -> None: |
| 10 |
fish_licence_root = rootdir / 'test-ext-apidoc-duplicates' |
| 11 |
|
| 12 |
sys_path = list(sys.path) |
| 13 |
sys.path.insert(0, str(fish_licence_root)) |
| 14 |
halibut = _import_module('fish_licence.halibut') |
| 15 |
sys.path[:] = sys_path |
| 16 |
|
| 17 |
assert halibut.__file__.endswith('halibut.pyi') |
| 18 |
assert halibut.__spec__.origin.endswith('halibut.pyi') |
| 19 |
|
| 20 |
halibut_path = Path(halibut.__file__).resolve() |
| 21 |
assert halibut_path.is_file() |
| 22 |
assert halibut_path == fish_licence_root / 'fish_licence' / 'halibut.pyi' |