Handle non-iterable arguments reasonable

This commit is contained in:
Alex Gaynor 2014-10-20 11:30:57 -07:00
parent d5b592d95d
commit 4f286cec7a
2 changed files with 5 additions and 0 deletions

View file

@ -131,6 +131,7 @@ class Fernet(object):
class MultiFernet(object):
def __init__(self, fernets):
fernets = list(fernets)
if not fernets:
raise ValueError(
"MultiFernet requires at least one Fernet instance"

View file

@ -146,3 +146,7 @@ class TestMultiFernet(object):
def test_no_fernets(self, backend):
with pytest.raises(ValueError):
MultiFernet([])
def test_non_iterable_argument(self, backend):
with pytest.raises(TypeError):
MultiFernet(None)