Fix NNTP when there's a ".netrc" file
This commit is contained in:
parent
2620d81b7f
commit
a5785b1524
|
@ -279,11 +279,12 @@ class _NNTPBase:
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
errors = 'surrogateescape'
|
errors = 'surrogateescape'
|
||||||
|
|
||||||
def __init__(self, file, user=None, password=None,
|
def __init__(self, file, host, user=None, password=None,
|
||||||
readermode=None, usenetrc=True,
|
readermode=None, usenetrc=True,
|
||||||
timeout=_GLOBAL_DEFAULT_TIMEOUT):
|
timeout=_GLOBAL_DEFAULT_TIMEOUT):
|
||||||
"""Initialize an instance. Arguments:
|
"""Initialize an instance. Arguments:
|
||||||
- file: file-like object (open for read/write in binary mode)
|
- file: file-like object (open for read/write in binary mode)
|
||||||
|
- host: hostname of the server (used if `usenetrc` is True)
|
||||||
- user: username to authenticate with
|
- user: username to authenticate with
|
||||||
- password: password to use with username
|
- password: password to use with username
|
||||||
- readermode: if true, send 'mode reader' command after
|
- readermode: if true, send 'mode reader' command after
|
||||||
|
@ -933,7 +934,7 @@ class NNTP(_NNTPBase):
|
||||||
self.port = port
|
self.port = port
|
||||||
self.sock = socket.create_connection((host, port), timeout)
|
self.sock = socket.create_connection((host, port), timeout)
|
||||||
file = self.sock.makefile("rwb")
|
file = self.sock.makefile("rwb")
|
||||||
_NNTPBase.__init__(self, file, user, password,
|
_NNTPBase.__init__(self, file, host, user, password,
|
||||||
readermode, usenetrc, timeout)
|
readermode, usenetrc, timeout)
|
||||||
|
|
||||||
def _close(self):
|
def _close(self):
|
||||||
|
|
|
@ -12,6 +12,7 @@ TIMEOUT = 30
|
||||||
# TODO:
|
# TODO:
|
||||||
# - test the `file` arg to more commands
|
# - test the `file` arg to more commands
|
||||||
# - test error conditions
|
# - test error conditions
|
||||||
|
# - test auth and `usenetrc`
|
||||||
|
|
||||||
|
|
||||||
class NetworkedNNTPTestsMixin:
|
class NetworkedNNTPTestsMixin:
|
||||||
|
@ -255,7 +256,7 @@ class MockedNNTPTestsMixin:
|
||||||
# isn't seekable.
|
# isn't seekable.
|
||||||
file = io.BufferedRWPair(self.sio, self.sio)
|
file = io.BufferedRWPair(self.sio, self.sio)
|
||||||
kwargs.setdefault('usenetrc', False)
|
kwargs.setdefault('usenetrc', False)
|
||||||
self.server = nntplib._NNTPBase(file, *args, **kwargs)
|
self.server = nntplib._NNTPBase(file, 'test.server', *args, **kwargs)
|
||||||
return self.server
|
return self.server
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue