test_cert_reload fails with ValueError on LDAS@CIT
If I clone this repo and run setup.py test
I get the following failure on ldas-pcdev2.ligo.caltech.edu:
$ python3.6 setup.py test --addopts "-k test_cert_reload"
running pytest
Searching for safe-netrc
Best match: safe-netrc 0.0.1
Processing safe_netrc-0.0.1-py3.6.egg
Using /home/duncan.macleod/git/ligo-requests/.eggs/safe_netrc-0.0.1-py3.6.egg
Searching for pytest-socket
Best match: pytest-socket 0.3.3
Processing pytest_socket-0.3.3-py3.6.egg
Using /home/duncan.macleod/git/ligo-requests/.eggs/pytest_socket-0.3.3-py3.6.egg
Searching for pytest-httpserver; python_version >= "3"
Best match: pytest-httpserver 0.3.4
Processing pytest_httpserver-0.3.4-py3.6.egg
Using /home/duncan.macleod/git/ligo-requests/.eggs/pytest_httpserver-0.3.4-py3.6.egg
Searching for pytest-freezegun
Best match: pytest-freezegun 0.3.0.post1
Processing pytest_freezegun-0.3.0.post1-py3.6.egg
Using /home/duncan.macleod/git/ligo-requests/.eggs/pytest_freezegun-0.3.0.post1-py3.6.egg
Searching for werkzeug
Best match: Werkzeug 0.16.0
Processing Werkzeug-0.16.0-py3.6.egg
Using /home/duncan.macleod/git/ligo-requests/.eggs/Werkzeug-0.16.0-py3.6.egg
running egg_info
writing ligo_requests.egg-info/PKG-INFO
writing dependency_links to ligo_requests.egg-info/dependency_links.txt
writing namespace_packages to ligo_requests.egg-info/namespace_packages.txt
writing requirements to ligo_requests.egg-info/requires.txt
writing top-level names to ligo_requests.egg-info/top_level.txt
reading manifest template 'MANIFEST.in'
writing manifest file 'ligo_requests.egg-info/SOURCES.txt'
running build_ext
======================================= test session starts ========================================
platform linux -- Python 3.6.8, pytest-4.6.6, py-1.8.0, pluggy-0.13.0
rootdir: /home/duncan.macleod/git/ligo-requests
plugins: freezegun-0.3.0.post1, httpserver-0.3.4, socket-0.3.3, forked-1.1.3, cov-2.5.1
collected 16 items / 15 deselected / 1 selected
ligo/requests/tests/test_cert_reload.py F [100%]
============================================= FAILURES =============================================
_________________________________________ test_cert_reload _________________________________________
cls = <class 'urllib3.util.timeout.Timeout'>
value = <requests.packages.urllib3.util.timeout.Timeout object at 0x7f45bcc73da0>, name = 'connect'
@classmethod
def _validate_timeout(cls, value, name):
""" Check that a timeout attribute is valid.
:param value: The timeout value to validate
:param name: The name of the timeout attribute to validate. This is
used to specify in error messages.
:return: The validated and casted version of the given value.
:raises ValueError: If it is a numeric value less than or equal to
zero, or the type is not an integer, float, or None.
"""
if value is _Default:
return cls.DEFAULT_TIMEOUT
if value is None or value is cls.DEFAULT_TIMEOUT:
return value
if isinstance(value, bool):
raise ValueError("Timeout cannot be a boolean value. It must "
"be an int, float or None.")
try:
> float(value)
E TypeError: float() argument must be a string or a number, not 'Timeout'
/usr/lib/python3.6/site-packages/urllib3/util/timeout.py:127: TypeError
During handling of the above exception, another exception occurred:
client = <ligo.requests.Session object at 0x7f45bdb2c828>
server = <pytest_httpserver.httpserver.HTTPServer object at 0x7f45bdb869b0>
freezer = <freezegun.api.FrozenDateTimeFactory object at 0x7f45bdb2ca58>
def test_cert_reload(client, server, freezer):
url = server.url_for('/')
# Test 1: significantly before expiration time, still valid
freezer.move_to('2019-01-02')
> assert client.get(url).json() == {'foo': 'bar'}
ligo/requests/tests/test_cert_reload.py:159:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.6/site-packages/requests/sessions.py:501: in get
return self.request('GET', url, **kwargs)
ligo/requests/file.py:76: in request
hooks=hooks, stream=stream, verify=verify, cert=cert, json=json)
/usr/lib/python3.6/site-packages/requests/sessions.py:488: in request
resp = self.send(prep, **send_kwargs)
/usr/lib/python3.6/site-packages/requests/sessions.py:609: in send
r = adapter.send(request, **kwargs)
/usr/lib/python3.6/site-packages/requests/adapters.py:423: in send
timeout=timeout
/usr/lib/python3.6/site-packages/urllib3/connectionpool.py:581: in urlopen
timeout_obj = self._get_timeout(timeout)
/usr/lib/python3.6/site-packages/urllib3/connectionpool.py:307: in _get_timeout
return Timeout.from_float(timeout)
/usr/lib/python3.6/site-packages/urllib3/util/timeout.py:157: in from_float
return Timeout(read=timeout, connect=timeout)
/usr/lib/python3.6/site-packages/urllib3/util/timeout.py:97: in __init__
self._connect = self._validate_timeout(connect, 'connect')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'urllib3.util.timeout.Timeout'>
value = <requests.packages.urllib3.util.timeout.Timeout object at 0x7f45bcc73da0>, name = 'connect'
@classmethod
def _validate_timeout(cls, value, name):
""" Check that a timeout attribute is valid.
:param value: The timeout value to validate
:param name: The name of the timeout attribute to validate. This is
used to specify in error messages.
:return: The validated and casted version of the given value.
:raises ValueError: If it is a numeric value less than or equal to
zero, or the type is not an integer, float, or None.
"""
if value is _Default:
return cls.DEFAULT_TIMEOUT
if value is None or value is cls.DEFAULT_TIMEOUT:
return value
if isinstance(value, bool):
raise ValueError("Timeout cannot be a boolean value. It must "
"be an int, float or None.")
try:
float(value)
except (TypeError, ValueError):
raise ValueError("Timeout value %s was %s, but it must be an "
> "int, float or None." % (name, value))
E ValueError: Timeout value connect was Timeout(connect=None, read=None, total=None), but it must be an int, float or None.
/usr/lib/python3.6/site-packages/urllib3/util/timeout.py:130: ValueError
---------------------------------------- Captured log call -----------------------------------------
WARNING urllib3.connectionpool:connectionpool.py:281 Connection pool is full, discarding connection: localhost
============================= 1 failed, 15 deselected in 1.13 seconds ==============================
Does this indicate some sort of version mismatch between requests
and urllib3
or similar? Or, is this really a bug in ligo-requests
?