I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra tests
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/requests-ftp-0.3.1
plugins: forked-1.4.0, xdist-2.5.0
collected 19 items
tests/test_ftp.py ............ [ 63%]
tests/test_ftp_proxy.py FFFF [ 84%]
tests/unit/test_status_code_interpret.py ... [100%]
================================================================================= FAILURES =================================================================================
______________________________________________________________________________ test_proxy_get ______________________________________________________________________________
ftpd = <simple_ftpd.SimpleFTPServer at 0x7f70b9596dc0>, proxy = <simple_proxy.ProxyServer object at 0x7f70b95c42e0>
session = <requests_ftp.ftp.FTPSession object at 0x7f70b958f7c0>
def test_proxy_get(ftpd, proxy, session):
# Create a file in the anonymous root and fetch it through a proxy
with _prepareTestData(ftpd.anon_root) as (testfile, testdata):
testurl = 'ftp://127.0.0.1:%d/%s' % (ftpd.ftp_port, testfile)
> response = session.get(testurl, proxies={'ftp': 'localhost:%d' % proxy.port})
tests/test_ftp_proxy.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/requests/sessions.py:542: in get
return self.request('GET', url, **kwargs)
/usr/lib/python3.8/site-packages/requests/sessions.py:529: in request
resp = self.send(prep, **send_kwargs)
/usr/lib/python3.8/site-packages/requests/sessions.py:645: in send
r = adapter.send(request, **kwargs)
../../BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages/requests_ftp/ftp.py:218: in send
return self.send_proxy(request, proxy, **kwargs)
../../BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages/requests_ftp/ftp.py:283: in send_proxy
adapter = s.get_adapter(proxy_url)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <requests_ftp.ftp.FTPSession object at 0x7f70b963cfa0>, url = 'localhost:///35693'
def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
# Nothing matches :-/
> raise InvalidSchema("No connection adapters were found for {!r}".format(url))
E requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:///35693'
/usr/lib/python3.8/site-packages/requests/sessions.py:732: InvalidSchema
______________________________________________________________________ test_proxy_connection_refused _______________________________________________________________________
ftpd = <simple_ftpd.SimpleFTPServer at 0x7f70b9596dc0>, session = <requests_ftp.ftp.FTPSession object at 0x7f70b845f6a0>
def test_proxy_connection_refused(ftpd, session):
# Create and bind a socket but do not listen to ensure we have a port
# that will refuse connections
def target(s, goevent):
goevent.set()
with socketServer(target) as port:
with pytest.raises(requests.exceptions.ConnectionError):
> session.get(
'ftp://127.0.0.1:%d/' % ftpd.ftp_port,
proxies={'ftp': 'localhost:%d' % port})
tests/test_ftp_proxy.py:58:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/requests/sessions.py:542: in get
return self.request('GET', url, **kwargs)
/usr/lib/python3.8/site-packages/requests/sessions.py:529: in request
resp = self.send(prep, **send_kwargs)
/usr/lib/python3.8/site-packages/requests/sessions.py:645: in send
r = adapter.send(request, **kwargs)
../../BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages/requests_ftp/ftp.py:218: in send
return self.send_proxy(request, proxy, **kwargs)
../../BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages/requests_ftp/ftp.py:283: in send_proxy
adapter = s.get_adapter(proxy_url)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <requests_ftp.ftp.FTPSession object at 0x7f70b95d0ca0>, url = 'localhost:///34353'
def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
# Nothing matches :-/
> raise InvalidSchema("No connection adapters were found for {!r}".format(url))
E requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:///34353'
/usr/lib/python3.8/site-packages/requests/sessions.py:732: InvalidSchema
_________________________________________________________________________ test_proxy_read_timeout __________________________________________________________________________
ftpd = <simple_ftpd.SimpleFTPServer at 0x7f70b9596dc0>, session = <requests_ftp.ftp.FTPSession object at 0x7f70b9584a00>
def test_proxy_read_timeout(ftpd, session):
# Create and accept a socket, but never respond
def target(s, goevent, event):
s.listen(1)
goevent.set()
(clientsock, _addr) = s.accept()
try:
event.wait(5)
finally:
clientsock.close()
event = threading.Event()
with socketServer(target, event) as port:
with pytest.raises(requests.exceptions.ReadTimeout):
> session.get(
'ftp://127.0.0.1:%d' % ftpd.ftp_port,
proxies={'ftp': 'localhost:%d' % port},
timeout=1)
tests/test_ftp_proxy.py:77:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/requests/sessions.py:542: in get
return self.request('GET', url, **kwargs)
/usr/lib/python3.8/site-packages/requests/sessions.py:529: in request
resp = self.send(prep, **send_kwargs)
/usr/lib/python3.8/site-packages/requests/sessions.py:645: in send
r = adapter.send(request, **kwargs)
../../BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages/requests_ftp/ftp.py:218: in send
return self.send_proxy(request, proxy, **kwargs)
../../BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages/requests_ftp/ftp.py:283: in send_proxy
adapter = s.get_adapter(proxy_url)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <requests_ftp.ftp.FTPSession object at 0x7f70b9621f10>, url = 'localhost:///45841'
def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
# Nothing matches :-/
> raise InvalidSchema("No connection adapters were found for {!r}".format(url))
E requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:///45841'
/usr/lib/python3.8/site-packages/requests/sessions.py:732: InvalidSchema
_______________________________________________________________________ test_proxy_connection_close ________________________________________________________________________
ftpd = <simple_ftpd.SimpleFTPServer at 0x7f70b9596dc0>, session = <requests_ftp.ftp.FTPSession object at 0x7f70b958bca0>
def test_proxy_connection_close(ftpd, session):
# Create and accept a socket, then close it
def target(s, goevent):
s.listen(1)
goevent.set()
(clientsock, _addr) = s.accept()
clientsock.close()
with socketServer(target) as port:
with pytest.raises(requests.exceptions.ConnectionError):
> session.get(
'ftp://127.0.0.1:%d/' % ftpd.ftp_port,
proxies={'ftp': 'localhost:%d' % port},
timeout=1)
tests/test_ftp_proxy.py:93:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/requests/sessions.py:542: in get
return self.request('GET', url, **kwargs)
/usr/lib/python3.8/site-packages/requests/sessions.py:529: in request
resp = self.send(prep, **send_kwargs)
/usr/lib/python3.8/site-packages/requests/sessions.py:645: in send
r = adapter.send(request, **kwargs)
../../BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages/requests_ftp/ftp.py:218: in send
return self.send_proxy(request, proxy, **kwargs)
../../BUILDROOT/python-requests-ftp-0.3.1-24.fc35.x86_64/usr/lib/python3.8/site-packages/requests_ftp/ftp.py:283: in send_proxy
adapter = s.get_adapter(proxy_url)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <requests_ftp.ftp.FTPSession object at 0x7f70b95e62e0>, url = 'localhost:///60247'
def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
# Nothing matches :-/
> raise InvalidSchema("No connection adapters were found for {!r}".format(url))
E requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:///60247'
/usr/lib/python3.8/site-packages/requests/sessions.py:732: InvalidSchema
========================================================================= short test summary info ==========================================================================
FAILED tests/test_ftp_proxy.py::test_proxy_get - requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:///35693'
FAILED tests/test_ftp_proxy.py::test_proxy_connection_refused - requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:///34353'
FAILED tests/test_ftp_proxy.py::test_proxy_read_timeout - requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:///45841'
FAILED tests/test_ftp_proxy.py::test_proxy_connection_close - requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:///60247'
======================================================================= 4 failed, 15 passed in 2.40s =======================================================================