Skip to content

Commit

Permalink
Add test for #379
Browse files Browse the repository at this point in the history
  • Loading branch information
aadamson committed Nov 29, 2018
1 parent 1b580ce commit 1245bd8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,37 @@ def test_func(tmpdir):
result = testdir.runpytest(n)
result.stdout.fnmatch_lines(["*UserWarning*foo.txt*", "*1 passed, 1 warnings*"])

@pytest.mark.parametrize("n", ["-n0", "-n1"])
def test_unserializable_warning_details(self, testdir, n):
"""Check that warnings with unserializable _WARNING_DETAILS are
handled correctly (#379).
"""
testdir.makepyfile(
"""
import warnings, pytest
import socket
import gc
def abuse_socket():
s = socket.socket()
del s
# Deliberately provoke a ResourceWarning for an unclosed socket.
# The socket itself will end up attached as a value in
# _WARNING_DETAIL. We need to test that it is not serialized
# (it can't be, so the test will fail if we try to).
def test_func(tmpdir):
warnings.resetwarnings()
warnings.simplefilter('always', ResourceWarning)
abuse_socket()
gc.collect()
"""
)
testdir.syspathinsert()
result = testdir.runpytest(n)
result.stdout.fnmatch_lines(
["*ResourceWarning*unclosed*", "*1 passed, 1 warnings*"]
)


class TestNodeFailure:
def test_load_single(self, testdir):
Expand Down

0 comments on commit 1245bd8

Please sign in to comment.