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