mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Seems like monkeypatching class methods doesn't work
This commit is contained in:
parent
43d6541d94
commit
8b7b55cdc2
1 changed files with 12 additions and 16 deletions
|
|
@ -37,15 +37,13 @@ def test_get_password_from_netrc(monkeypatch):
|
||||||
|
|
||||||
calls = []
|
calls = []
|
||||||
|
|
||||||
def authenticators(self, hostname):
|
class Netrc(object):
|
||||||
calls.append(hostname)
|
def authenticators(self, hostname):
|
||||||
return username, 'bogus', password
|
calls.append(hostname)
|
||||||
|
return username, 'bogus', password
|
||||||
|
|
||||||
import netrc
|
monkeypatch.setattr('netrc.netrc', Netrc)
|
||||||
monkeypatch.setattr(netrc.netrc, 'authenticators', authenticators)
|
monkeypatch.setattr('getpass.getpass', None)
|
||||||
|
|
||||||
import getpass
|
|
||||||
monkeypatch.setattr(getpass, 'getpass', None)
|
|
||||||
|
|
||||||
_password = utils.get_password(username, resource)
|
_password = utils.get_password(username, resource)
|
||||||
assert _password == password
|
assert _password == password
|
||||||
|
|
@ -81,17 +79,15 @@ def test_get_password_from_system_keyring(monkeypatch, resources_to_test):
|
||||||
import sys
|
import sys
|
||||||
monkeypatch.setitem(sys.modules, 'keyring', KeyringMock())
|
monkeypatch.setitem(sys.modules, 'keyring', KeyringMock())
|
||||||
|
|
||||||
import netrc
|
|
||||||
netrc_calls = []
|
netrc_calls = []
|
||||||
|
|
||||||
def authenticators(self, hostname):
|
class Netrc(object):
|
||||||
netrc_calls.append(hostname)
|
def authenticators(self, hostname):
|
||||||
return None
|
netrc_calls.append(hostname)
|
||||||
|
return None
|
||||||
|
|
||||||
monkeypatch.setattr(netrc.netrc, 'authenticators', authenticators)
|
monkeypatch.setattr('netrc.netrc', Netrc)
|
||||||
|
monkeypatch.setattr('getpass.getpass', None)
|
||||||
import getpass
|
|
||||||
monkeypatch.setattr(getpass, 'getpass', None)
|
|
||||||
|
|
||||||
_password = utils.get_password(username, resource)
|
_password = utils.get_password(username, resource)
|
||||||
assert _password == password
|
assert _password == password
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue