From 29f1ce38d8b2e4c8e5e9d67fd84b8f75d507932a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 2 Jan 2020 16:52:36 +0100 Subject: [PATCH] Fix test_conflicting_post_params to work on pytest 5 The non-contextmanager form of pytest.raises was removed in pytest 5. http://doc.pytest.org/en/latest/deprecations.html#raises-warns-with-a-string-as-the-second-argument It was used here to support Python < 2.7, but that is no longer needed. https://github.com/psf/requests/pull/1503#issuecomment-22333666 Fixes https://github.com/psf/requests/issues/5304 --- tests/test_requests.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_requests.py b/tests/test_requests.py index 7d4a4eb510..e730f7648b 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -774,8 +774,10 @@ def __len__(self): def test_conflicting_post_params(self, httpbin): url = httpbin('post') with open('Pipfile') as f: - pytest.raises(ValueError, "requests.post(url, data='[{\"some\": \"data\"}]', files={'some': f})") - pytest.raises(ValueError, "requests.post(url, data=u('[{\"some\": \"data\"}]'), files={'some': f})") + with pytest.raises(ValueError): + requests.post(url, data='[{"some": "data"}]', files={'some': f}) + with pytest.raises(ValueError): + requests.post(url, data=u('[{"some": "data"}]'), files={'some': f}) def test_request_ok_set(self, httpbin): r = requests.get(httpbin('status', '404'))