From c1ea0a0d23115bb0586230a139bcb2b60adb6262 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 31 Oct 2013 15:03:53 -0700 Subject: Fixed pep8 issues --- cryptography/fernet.py | 8 ++++++-- tests/test_fernet.py | 10 ++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cryptography/fernet.py b/cryptography/fernet.py index 880d96f0..ef64b7e9 100644 --- a/cryptography/fernet.py +++ b/cryptography/fernet.py @@ -28,7 +28,9 @@ class Fernet(object): def _encrypt_from_parts(self, data, current_time, iv): if isinstance(data, six.text_type): - raise TypeError("Unicode-objects must be encoded before encryption") + raise TypeError( + "Unicode-objects must be encoded before encryption" + ) padder = padding.PKCS7(ciphers.AES.block_size).padder() padded_data = padder.update(data) + padder.finalize() @@ -49,7 +51,9 @@ class Fernet(object): def decrypt(self, data, ttl=None, current_time=None): if isinstance(data, six.text_type): - raise TypeError("Unicode-objects must be encoded before decryption") + raise TypeError( + "Unicode-objects must be encoded before decryption" + ) if current_time is None: current_time = int(time.time()) diff --git a/tests/test_fernet.py b/tests/test_fernet.py index 15071718..b0f22f0c 100644 --- a/tests/test_fernet.py +++ b/tests/test_fernet.py @@ -40,21 +40,19 @@ class TestFernet(object): ) def test_verify(self, secret, now, src, ttl_sec, token): f = Fernet(base64.urlsafe_b64decode(secret.encode("ascii"))) + current_time = calendar.timegm(iso8601.parse_date(now).utctimetuple()) payload = f.decrypt( - token.encode("ascii"), - ttl=ttl_sec, - current_time=calendar.timegm(iso8601.parse_date(now).utctimetuple()) + token.encode("ascii"), ttl=ttl_sec, current_time=current_time ) assert payload == src @json_parametrize(("secret", "token", "now", "ttl_sec"), "invalid.json") def test_invalid(self, secret, token, now, ttl_sec): f = Fernet(base64.urlsafe_b64decode(secret.encode("ascii"))) + current_time = calendar.timegm(iso8601.parse_date(now).utctimetuple()) with pytest.raises(InvalidToken): f.decrypt( - token.encode("ascii"), - ttl=ttl_sec, - current_time=calendar.timegm(iso8601.parse_date(now).utctimetuple()) + token.encode("ascii"), ttl=ttl_sec, current_time=current_time ) def test_unicode(self): -- cgit v1.2.3