Fix a bug in parse_options

This commit is contained in:
Markus Unterwaditzer 2014-04-08 22:07:13 +02:00
parent 745afbe5a3
commit 691abf8c7e
3 changed files with 16 additions and 8 deletions

View file

@ -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'

View file

@ -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):

View file

@ -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