pytest-xdist assumes `ExceptionChainRepr` is hashable.
Fixes https://github.com/pytest-dev/pytest/issues/6925.
Fixes https://github.com/pytest-dev/pytest-xdist/issues/515.
(cherry picked from commit 20f6331afd)
This commit is contained in:
@@ -6,6 +6,7 @@ import pytest
|
||||
from _pytest._code import Code
|
||||
from _pytest._code import ExceptionInfo
|
||||
from _pytest._code import Frame
|
||||
from _pytest._code.code import ExceptionChainRepr
|
||||
from _pytest._code.code import ReprFuncArgs
|
||||
|
||||
|
||||
@@ -180,3 +181,20 @@ class TestReprFuncArgs:
|
||||
tw_mock.lines[0]
|
||||
== r"unicode_string = São Paulo, utf8_string = b'S\xc3\xa3o Paulo'"
|
||||
)
|
||||
|
||||
|
||||
def test_ExceptionChainRepr():
|
||||
"""Test ExceptionChainRepr, especially with regard to being hashable."""
|
||||
try:
|
||||
raise ValueError()
|
||||
except ValueError:
|
||||
excinfo1 = ExceptionInfo.from_current()
|
||||
excinfo2 = ExceptionInfo.from_current()
|
||||
|
||||
repr1 = excinfo1.getrepr()
|
||||
repr2 = excinfo2.getrepr()
|
||||
assert repr1 != repr2
|
||||
|
||||
assert isinstance(repr1, ExceptionChainRepr)
|
||||
assert hash(repr1) != hash(repr2)
|
||||
assert repr1 is not excinfo1.getrepr()
|
||||
|
||||
Reference in New Issue
Block a user