From 6e1cbe9bbce5194a2d5b9c6e78b6637ad4d5bc5c Mon Sep 17 00:00:00 2001 From: Dhia Bouassida Date: Mon, 2 Sep 2024 11:50:43 +0200 Subject: [PATCH] fix failing test --- test/integ/test_vendored_urllib.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integ/test_vendored_urllib.py b/test/integ/test_vendored_urllib.py index 3d6f27f9b..24441bff2 100644 --- a/test/integ/test_vendored_urllib.py +++ b/test/integ/test_vendored_urllib.py @@ -30,12 +30,12 @@ def _execute_request(): return resp _execute_request() - try: + + major_version = int(urllib3.__version__.split(".")[0]) + + if major_version < 2: + with pytest.raises(ValueError, match="file descriptor cannot be a negative"): + _execute_request() + else: + # In case of urllib3 version >= 2, just execute the request without expecting an error _execute_request() - except ValueError as e: - if "file descriptor cannot be a negative" in str(e): - raise AssertionError( - "Second _execute_request failed. See linked github issue comment" - ) - else: - raise e