Handle unserializable warning arguments

Fix #349
This commit is contained in:
Bruno Oliveira
2018-10-29 18:47:43 -03:00
parent 70688b7986
commit b151e56fbd
4 changed files with 37 additions and 4 deletions

View File

@@ -766,6 +766,23 @@ class TestWarnings:
result = testdir.runpytest(n)
result.stdout.fnmatch_lines(["*MyWarning*", "*1 passed, 1 warnings*"])
@pytest.mark.parametrize("n", ["-n0", "-n1"])
def test_unserializable_arguments(self, testdir, n):
"""Check that warnings with unserializable arguments are handled correctly (#349)."""
testdir.makepyfile(
"""
import warnings, pytest
def test_func(tmpdir):
fn = (tmpdir / 'foo.txt').ensure(file=1)
with fn.open('r') as f:
warnings.warn(UserWarning("foo", f))
"""
)
testdir.syspathinsert()
result = testdir.runpytest(n)
result.stdout.fnmatch_lines(["*UserWarning*foo.txt*", "*1 passed, 1 warnings*"])
class TestNodeFailure:
def test_load_single(self, testdir):