def __init__(self, destdir, persist_limit, **kwargs): QObject.__init__(self) persist_limit = PersistLimit(persist_limit) BuildDownloadManager.__init__(self, destdir, session=get_http_session(), persist_limit=persist_limit, **kwargs)
def __init__(self, destdir, persist_limit, **kwargs): QObject.__init__(self) BuildDownloadManager.__init__(self, destdir, session=get_http_session(), persist_limit=persist_limit, **kwargs)
def test_set_http_session(): try: with patch('requests.Session') as Session: session = Session.return_value = Mock() session_get = session.get network.set_http_session(get_defaults={'timeout': 5}) assert session == network.get_http_session() # timeout = 5 will be passed to the original get method as a default session.get('http://my-ul') session_get.assert_called_with('http://my-ul', timeout=5) # if timeout is defined, it will override the default session.get('http://my-ul', timeout=10) session_get.assert_called_with('http://my-ul', timeout=10) finally: # remove the global session to not impact other tests network.SESSION = None