Skip to content

Commit 0742f6f

Browse files
committed
improve test to check errors roundtrip
1 parent fa94118 commit 0742f6f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/errors/validation_exception.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl ValidationError {
347347
let callable = slf.getattr("from_exception_data")?;
348348
let borrow = slf.try_borrow()?;
349349
let args = (
350-
borrow.title.as_ref(slf.py()),
350+
borrow.title.as_ref(py),
351351
borrow.errors(py, include_url_env(py), true, true)?,
352352
borrow.input_type.into_py(py),
353353
borrow.hide_input,

tests/test_errors.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,9 +1077,14 @@ def test_hide_input_in_json() -> None:
10771077
assert 'input' not in error
10781078

10791079

1080+
@pytest.mark.skipif(
1081+
sys.version_info < (3, 9) and sys.implementation == 'pypy', reason='PyPy before 3.9 cannot pickle this correctly'
1082+
)
10801083
def test_validation_error_pickle() -> None:
10811084
s = SchemaValidator({'type': 'int'})
10821085
with pytest.raises(ValidationError) as exc_info:
10831086
s.validate_python('definitely not an int')
10841087

1085-
pickle.loads(pickle.dumps(exc_info.value))
1088+
original = exc_info.value
1089+
roundtripped = pickle.loads(pickle.dumps(original))
1090+
assert original.errors() == roundtripped.errors()

0 commit comments

Comments
 (0)