Skip to content

Commit ce24626

Browse files
authored
test: use the correct ConnectionError class in the tests (#198)
A recently introduced unit test uses the ConnectionError class from the standard library to check the type of a returned exception, but that's not correct because the actual exception that can be thrown there is the requests.exceptions.ConnectionError. This confusion made the tests fail sometimes. Signed-off-by: Norbert Biczo <[email protected]>
1 parent 6751215 commit ce24626

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/test_http_adapter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import pytest
1010
import urllib3
11-
from requests.exceptions import SSLError
11+
from requests import exceptions
1212

1313
from ibm_cloud_sdk_core.base_service import BaseService
1414
from ibm_cloud_sdk_core.authenticators import NoAuthAuthenticator
@@ -71,7 +71,7 @@ def test_tls_v1_1():
7171
with pytest.raises(Exception) as exception:
7272
service.send(prepped, verify=cert)
7373
# Errors can be differ based on the Python version.
74-
assert exception.type is SSLError or exception.type is ConnectionError
74+
assert exception.type is exceptions.SSLError or exception.type is exceptions.ConnectionError
7575

7676

7777
@_local_server(PROTOCOL_TLSv1_2, 3334)
@@ -82,7 +82,7 @@ def test_tls_v1_2():
8282
# It should fail due to the self-signed SSL cert.
8383
assert service.disable_ssl_verification is False
8484
prepped = service.prepare_request('GET', url='/')
85-
with pytest.raises(SSLError, match='certificate verify failed: self-signed certificate'):
85+
with pytest.raises(exceptions.SSLError, match='certificate verify failed: self-signed certificate'):
8686
res = service.send(prepped)
8787

8888
# Next configure it to validate by using our local certificate. Should raise no exception.

0 commit comments

Comments
 (0)