MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_importorskip_module_level

Function test_importorskip_module_level

testing/test_runner.py:749–761  ·  view source on GitHub ↗

`importorskip` must be able to skip entire modules when used at module level.

(pytester: Pytester)

Source from the content-addressed store, hash-verified

747
748
749def test_importorskip_module_level(pytester: Pytester) -> None:
750 """`importorskip` must be able to skip entire modules when used at module level."""
751 pytester.makepyfile(
752 """
753 import pytest
754 foobarbaz = pytest.importorskip("foobarbaz")
755
756 def test_foo():
757 pass
758 """
759 )
760 result = pytester.runpytest()
761 result.stdout.fnmatch_lines(["*collected 0 items / 1 skipped*"])
762
763
764def test_importorskip_custom_reason(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected