File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -803,6 +803,37 @@ def test_func(tmpdir):
803
803
result = testdir .runpytest (n )
804
804
result .stdout .fnmatch_lines (["*UserWarning*foo.txt*" , "*1 passed, 1 warnings*" ])
805
805
806
+ @pytest .mark .parametrize ("n" , ["-n0" , "-n1" ])
807
+ def test_unserializable_warning_details (self , testdir , n ):
808
+ """Check that warnings with unserializable _WARNING_DETAILS are
809
+ handled correctly (#379).
810
+ """
811
+ testdir .makepyfile (
812
+ """
813
+ import warnings, pytest
814
+ import socket
815
+ import gc
816
+ def abuse_socket():
817
+ s = socket.socket()
818
+ del s
819
+
820
+ # Deliberately provoke a ResourceWarning for an unclosed socket.
821
+ # The socket itself will end up attached as a value in
822
+ # _WARNING_DETAIL. We need to test that it is not serialized
823
+ # (it can't be, so the test will fail if we try to).
824
+ def test_func(tmpdir):
825
+ warnings.resetwarnings()
826
+ warnings.simplefilter('always', ResourceWarning)
827
+ abuse_socket()
828
+ gc.collect()
829
+ """
830
+ )
831
+ testdir .syspathinsert ()
832
+ result = testdir .runpytest (n )
833
+ result .stdout .fnmatch_lines (
834
+ ["*ResourceWarning*unclosed*" , "*1 passed, 1 warnings*" ]
835
+ )
836
+
806
837
807
838
class TestNodeFailure :
808
839
def test_load_single (self , testdir ):
You can’t perform that action at this time.
0 commit comments