mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-24 14:27:41 +00:00
Fix a bug in parse_options
This commit is contained in:
parent
745afbe5a3
commit
691abf8c7e
3 changed files with 16 additions and 8 deletions
|
|
@ -21,7 +21,9 @@ def test_parse_options():
|
|||
'asd': 'off'
|
||||
}
|
||||
|
||||
assert dict(utils.parse_options(o.items())) == {
|
||||
a = dict(utils.parse_options(o.items()))
|
||||
|
||||
expected = {
|
||||
'foo': True,
|
||||
'hah': True,
|
||||
'bar': '',
|
||||
|
|
@ -30,6 +32,11 @@ def test_parse_options():
|
|||
'asd': False
|
||||
}
|
||||
|
||||
assert a == expected
|
||||
|
||||
for key in a:
|
||||
assert type(a[key]) is type(expected[key])
|
||||
|
||||
|
||||
def test_get_password_from_netrc(monkeypatch):
|
||||
username = 'foouser'
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ def prepare_auth(auth, username, password):
|
|||
|
||||
|
||||
def prepare_verify(verify):
|
||||
if isinstance(verify, bool):
|
||||
return verify
|
||||
return expand_path(verify)
|
||||
if isinstance(verify, (str, unicode)):
|
||||
return expand_path(verify)
|
||||
return verify
|
||||
|
||||
|
||||
class HttpStorageBase(Storage):
|
||||
|
|
|
|||
|
|
@ -50,10 +50,11 @@ def parse_options(items):
|
|||
value = True
|
||||
elif value.lower() in ('no', 'false', 'off'):
|
||||
value = False
|
||||
try:
|
||||
value = int(value)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
value = int(value)
|
||||
except ValueError:
|
||||
pass
|
||||
yield key, value
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue