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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
From 36da765cfc27cd6bda5c2773e3b3664a6473cd3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Thu, 15 Feb 2024 15:53:50 +0100
Subject: [PATCH] Remove spurious `pytest.warns()` to fix pytest-8
compatibility
Remove the spurious `pytest.warns()` contexts within `pytest.raises()`
in `test_shortcuts`, in order to fix compatibility with pytest-8.0.0.
Prior to this version, the exception raised caused these assertions
to be ignored entirely. This is fixed in pytest-8.0.0, and the tests
start failing because the warning is never raised prior
to the exception.
Fixes #789
---
tests/unit/test_shortcuts.py | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/tests/unit/test_shortcuts.py b/tests/unit/test_shortcuts.py
index 0dd1865..9a3f36c 100644
--- a/tests/unit/test_shortcuts.py
+++ b/tests/unit/test_shortcuts.py
@@ -423,8 +423,7 @@ class TestUnmarshalResponse:
mock_unmarshal.return_value = ResultMock(error_to_raise=ValueError)
with pytest.raises(ValueError):
- with pytest.warns(DeprecationWarning):
- unmarshal_response(request, response, spec=spec_v31)
+ unmarshal_response(request, response, spec=spec_v31)
mock_unmarshal.assert_called_once_with(request, response)
@@ -597,15 +596,13 @@ class TestValidateRequest:
request = mock.Mock(spec=Request)
with pytest.raises(SpecError):
- with pytest.warns(DeprecationWarning):
- validate_request(request, spec=spec_invalid)
+ validate_request(request, spec=spec_invalid)
def test_spec_not_detected(self, spec_v20):
request = mock.Mock(spec=Request)
with pytest.raises(SpecError):
- with pytest.warns(DeprecationWarning):
- validate_request(request, spec=spec_v20)
+ validate_request(request, spec=spec_v20)
def test_request_type_invalid(self, spec_v31):
request = mock.sentinel.request
@@ -733,8 +730,7 @@ class TestValidateRequest:
request = mock.Mock(spec=WebhookRequest)
with pytest.raises(SpecError):
- with pytest.warns(DeprecationWarning):
- validate_request(request, spec=spec_v30)
+ validate_request(request, spec=spec_v30)
@mock.patch(
"openapi_core.validation.request.validators.V31WebhookRequestValidator."
@@ -889,16 +885,14 @@ class TestValidateResponse:
response = mock.Mock(spec=Response)
with pytest.raises(SpecError):
- with pytest.warns(DeprecationWarning):
- validate_response(request, response, spec=spec_invalid)
+ validate_response(request, response, spec=spec_invalid)
def test_spec_not_supported(self, spec_v20):
request = mock.Mock(spec=Request)
response = mock.Mock(spec=Response)
with pytest.raises(SpecError):
- with pytest.warns(DeprecationWarning):
- validate_response(request, response, spec=spec_v20)
+ validate_response(request, response, spec=spec_v20)
def test_request_type_invalid(self, spec_v31):
request = mock.sentinel.request
@@ -965,8 +959,7 @@ class TestValidateResponse:
response = mock.Mock(spec=Response)
with pytest.raises(SpecError):
- with pytest.warns(DeprecationWarning):
- validate_response(request, response, spec=spec_v30)
+ validate_response(request, response, spec=spec_v30)
@mock.patch(
"openapi_core.validation.response.validators.V31WebhookResponseValidator."
--
2.43.1
|