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