def test_importorskip_module_level(testdir):
 testdir.makepyfile('\n        import pytest\n        foobarbaz = pytest.importorskip("foobarbaz")\n\n        def test_foo():\n            pass\n    ')
 result = testdir.runpytest()
 result.stdout.fnmatch_lines(['*collected 0 items / 1 skipped*'])

def test_importorskip_module_level ( testdir ) : testdir . makepyfile ( '\n        import pytest\n        foobarbaz = pytest.importorskip("foobarbaz")\n\n        def test_foo():\n            pass\n    ' ) result = testdir . runpytest ( ) result . stdout . fnmatch_lines ( [ '*collected 0 items / 1 skipped*' ] )
importorskip must be able to skip entire modules when used at module level .