add tests

This commit is contained in:
Thomas Grainger 2023-10-19 18:17:27 +01:00
parent f34091f0ec
commit 5ba3351b52
No known key found for this signature in database
GPG Key ID: DDA48B5C47FBC8C8
1 changed files with 20 additions and 0 deletions

View File

@ -1428,6 +1428,26 @@ def test_importorskip() -> None:
pytest.importorskip("doesnotexist")
def test_importorskip_module_not_found() -> None:
with pytest.raises(
pytest.skip.Exception,
match="^could not import 'doesnotexist': No module named .*",
):
pytest.importorskip("doesnotexist", exc=ModuleNotFoundError)
def test_importorskip_module_not_found_raises_on_import_error(monkeypatch, tmp_path) -> None:
on_path = tmp_path / "on_path"
on_path.mkdir()
(on_path / "doesnotexist.py").write_bytes(b"1 / 0")
monkeypatch.syspath_prepend(some_dir)
with pytest.raises(ImportError):
pytest.importorskip("doesnotexist", exc=ModuleNotFoundError)
def test_relpath_rootdir(pytester: Pytester) -> None:
pytester.makepyfile(
**{