Add test case for `importorskip` custom reason

This commit is contained in:
Pedro Algarvio 2019-01-04 19:02:07 +00:00
parent 8b48621687
commit be7eb22e88
No known key found for this signature in database
GPG Key ID: BB36BF6584A298FF
1 changed files with 16 additions and 0 deletions

View File

@ -738,6 +738,22 @@ def test_importorskip_module_level(testdir):
result.stdout.fnmatch_lines(["*collected 0 items / 1 skipped*"])
def test_importorskip_custom_reason(testdir):
"""make sure custom reasons are used"""
testdir.makepyfile(
"""
import pytest
foobarbaz = pytest.importorskip("foobarbaz2", reason="just because")
def test_foo():
pass
"""
)
result = testdir.runpytest("-ra")
result.stdout.fnmatch_lines(["*just because*"])
result.stdout.fnmatch_lines(["*collected 0 items / 1 skipped*"])
def test_pytest_cmdline_main(testdir):
p = testdir.makepyfile(
"""