diff --git a/.coveragerc b/.coveragerc index f4163257..ac4a77f9 100644 --- a/.coveragerc +++ b/.coveragerc @@ -10,5 +10,6 @@ omit = exclude_lines = pragma: no cover if __name__ == .__main__.: + except .*ImportError.*: except .*UnicodeDecodeError.*: except .*urllib3.exceptions.*: diff --git a/tests/downloads_tests.py b/tests/downloads_tests.py index 28644316..ea6f1c15 100644 --- a/tests/downloads_tests.py +++ b/tests/downloads_tests.py @@ -51,16 +51,20 @@ def test_fetch(): else: assert fetch_url('1234') == '' assert fetch_url('https://httpbin.org/status/404') is None + # empty request? + #assert _send_request('') is None # test if the fonctions default to no_ssl assert _send_request('https://expired.badssl.com/', False, DEFAULT_CONFIG) is not None if pycurl is not None: assert _send_pycurl_request('https://expired.badssl.com/', False, DEFAULT_CONFIG) is not None # no SSL, no decoding + url = 'https://httpbin.org/status/200' response = _send_request('https://httpbin.org/status/200', True, DEFAULT_CONFIG) assert response.data == b'' if pycurl is not None: - response = _send_pycurl_request('https://httpbin.org/status/200', True, DEFAULT_CONFIG) - assert response.data == b'' + response1 = _send_pycurl_request('https://httpbin.org/status/200', True, DEFAULT_CONFIG) + assert _handle_response(url, response1, False, DEFAULT_CONFIG) == _handle_response(url, response, False, DEFAULT_CONFIG) + assert _handle_response(url, response1, True, DEFAULT_CONFIG) == _handle_response(url, response, True, DEFAULT_CONFIG) # response object url = 'https://httpbin.org/encoding/utf8' response = _send_request(url, False, DEFAULT_CONFIG) @@ -68,8 +72,13 @@ def test_fetch(): assert myobject.data.startswith(b'
This here is the text.
This here is the text.