From 427e8eb1e7559ac4739c04069310be18ddbb734f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Sat, 9 May 2020 06:58:03 +0200 Subject: [PATCH] Fix test_conflicting_post_params to work on pytest 5 (#5305) 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 7d4a4eb5..e730f764 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -774,8 +774,10 @@ class TestRequests: 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'))