Skip to content

Commit e4ad03f

Browse files
committed
Work around flaky test
1 parent 443379f commit e4ad03f

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

tests/test_errors.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@ def test_errors_pickling(
4242
before = err_cls(*err_args)
4343

4444
assert before.args == err_args
45+
after = pickle.loads(pickle.dumps(before)) # noqa: S301
4546

46-
with (tmp_path / (err_cls.__name__.lower() + ".pypickle")).open("wb") as f:
47-
pickle.dump(before, f)
47+
assert isinstance(after, err_cls)
4848

49-
with (tmp_path / (err_cls.__name__.lower() + ".pypickle")).open("rb") as f:
50-
after = pickle.load(f) # noqa: S301
49+
if err_cls is ForbiddenExtraKeysError and err_args[0] == "":
50+
# This comparison is slightly tricky since this class uses sets, which do
51+
# not have a stable ordering.
52+
# We skip it and rely on comparing the args below.
53+
pass
54+
else:
55+
assert str(after) == str(before)
5156

52-
assert isinstance(after, err_cls)
53-
assert str(after) == str(before)
5457
if issubclass(err_cls, ExceptionGroup):
5558
assert after.message == before.message
5659
assert after.args[0] == before.args[0]

0 commit comments

Comments
 (0)