Skip to content

Commit

Permalink
WIP add test for pytest-dev#349
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Sep 29, 2018
1 parent 86e2fb5 commit 4a15982
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def test_func(request):
result.stdout.fnmatch_lines(["*this is a warning*", "*1 passed, 1 warnings*"])

@pytest.mark.parametrize("n", ["-n0", "-n1"])
def test_custom_subclass(self, testdir, n):
def test_custom_warning_subclass(self, testdir, n):
"""Check that warning subclasses that don't honor the args attribute don't break
pytest-xdist (#344)
"""
Expand Down Expand Up @@ -458,6 +458,27 @@ def test_func(request):
result = testdir.runpytest(n)
result.stdout.fnmatch_lines(["*MyWarning*", "*1 passed, 1 warnings*"])

@pytest.mark.parametrize("n", ["-n0", "-n1"])
def test_warning_unserializable_arg(self, testdir, n):
"""Check that warning with args that can't be serialized don't choke xdist (#349)"""
from pkg_resources import parse_version

if parse_version(pytest.__version__) < parse_version("3.1"):
pytest.skip("pytest warnings requires >= 3.1")

testdir.makepyfile(
"""
import warnings
def test_func(tmpdir):
with open(str(tmpdir / 'foo.txt'), 'w') as f:
warnings.warn(UserWarning(f))
"""
)
testdir.syspathinsert()
result = testdir.runpytest(n)
result.stdout.fnmatch_lines(["*UserWarning*foo.txt*", "*1 passed, 1 warnings*"])

def test_logfinish_hook(self, testdir):
"""Ensure the pytest_runtest_logfinish hook is being properly handled"""
from _pytest import hookspec
Expand Down

0 comments on commit 4a15982

Please sign in to comment.