aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-31 15:03:53 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-31 15:03:53 -0700
commitc1ea0a0d23115bb0586230a139bcb2b60adb6262 (patch)
tree53ba668e063ed7221c16608cca69516ad4a702f4
parent484713ffd0cb96ee36173363b6733d6b3dd32b4d (diff)
downloadcryptography-c1ea0a0d23115bb0586230a139bcb2b60adb6262.tar.gz
cryptography-c1ea0a0d23115bb0586230a139bcb2b60adb6262.tar.bz2
cryptography-c1ea0a0d23115bb0586230a139bcb2b60adb6262.zip
Fixed pep8 issues
-rw-r--r--cryptography/fernet.py8
-rw-r--r--tests/test_fernet.py10
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):