summaryrefslogtreecommitdiff
path: root/backport-Fix-test_assert_raises_validation_error-with-pytest-8.patch
blob: c4a981c4418a3d8d14d56231928b4e59b622c61a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 22f86ad2ae1df0e1ca33a93275a1dd69d9d50988 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Sat, 16 Mar 2024 09:57:41 +0100
Subject: [PATCH] Fix `test_assert_raises_validation_error` with pytest-8
 (#8995) (#9024)

---
 tests/test_validators.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/test_validators.py b/tests/test_validators.py
index 09311f6007..c2039a19b8 100644
--- a/tests/test_validators.py
+++ b/tests/test_validators.py
@@ -808,16 +808,16 @@
 
         @validator('a')
         def check_a(cls, v):
-            assert v == 'a', 'invalid a'
+            if v != 'a':
+                raise AssertionError('invalid a')
             return v
 
     Model(a='a')
 
     with pytest.raises(ValidationError) as exc_info:
         Model(a='snap')
-    injected_by_pytest = "\nassert 'snap' == 'a'\n  - a\n  + snap"
     assert exc_info.value.errors() == [
-        {'loc': ('a',), 'msg': f'invalid a{injected_by_pytest}', 'type': 'assertion_error'}
+        {'loc': ('a',), 'msg': 'invalid a', 'type': 'assertion_error'}
     ]