summaryrefslogtreecommitdiff
path: root/tests/crypto_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/crypto_test.py')
-rw-r--r--tests/crypto_test.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/crypto_test.py b/tests/crypto_test.py
index 25cce8ba..c3db1055 100644
--- a/tests/crypto_test.py
+++ b/tests/crypto_test.py
@@ -59,7 +59,8 @@ def tearDownModule():
lookfor = 'gpg-agent --homedir {}'.format(os.environ['GNUPGHOME'])
out = subprocess.check_output(
- ['ps', 'xo', 'pid,cmd'], stderr=DEVNULL).decode(urwid.util.detected_encoding)
+ ['ps', 'xo', 'pid,cmd'],
+ stderr=DEVNULL).decode(urwid.util.detected_encoding)
for each in out.strip().split('\n'):
pid, cmd = each.strip().split(' ', 1)
if cmd.startswith(lookfor):
@@ -113,7 +114,8 @@ class TestDetachedSignatureFor(unittest.TestCase):
def test_valid_signature_generated(self):
to_sign = b"this is some text.\nit is more than nothing.\n"
with gpg.core.Context() as ctx:
- _, detached = crypto.detached_signature_for(to_sign, [ctx.get_key(FPR)])
+ _, detached = crypto.detached_signature_for(
+ to_sign, [ctx.get_key(FPR)])
with tempfile.NamedTemporaryFile(delete=False) as f:
f.write(detached)
@@ -135,7 +137,8 @@ class TestVerifyDetached(unittest.TestCase):
def test_verify_signature_good(self):
to_sign = b"this is some text.\nIt's something\n."
with gpg.core.Context() as ctx:
- _, detached = crypto.detached_signature_for(to_sign, [ctx.get_key(FPR)])
+ _, detached = crypto.detached_signature_for(
+ to_sign, [ctx.get_key(FPR)])
try:
crypto.verify_detached(to_sign, detached)
@@ -146,7 +149,8 @@ class TestVerifyDetached(unittest.TestCase):
to_sign = b"this is some text.\nIt's something\n."
similar = b"this is some text.\r\n.It's something\r\n."
with gpg.core.Context() as ctx:
- _, detached = crypto.detached_signature_for(to_sign, [ctx.get_key(FPR)])
+ _, detached = crypto.detached_signature_for(
+ to_sign, [ctx.get_key(FPR)])
with self.assertRaises(GPGProblem):
crypto.verify_detached(similar, detached)
@@ -180,7 +184,8 @@ class TestValidateKey(unittest.TestCase):
def test_encrypt(self):
with self.assertRaises(GPGProblem) as caught:
- crypto.validate_key(utilities.make_key(can_encrypt=False), encrypt=True)
+ crypto.validate_key(
+ utilities.make_key(can_encrypt=False), encrypt=True)
self.assertEqual(caught.exception.code, GPGCode.KEY_CANNOT_ENCRYPT)
@@ -286,7 +291,8 @@ class TestGetKey(unittest.TestCase):
# once.
with gpg.core.Context() as ctx:
expected = ctx.get_key(FPR).uids[0].uid
- actual = crypto.get_key(FPR, validate=True, encrypt=True, sign=True).uids[0].uid
+ actual = crypto.get_key(
+ FPR, validate=True, encrypt=True, sign=True).uids[0].uid
self.assertEqual(expected, actual)
def test_missing_key(self):
@@ -306,7 +312,8 @@ class TestGetKey(unittest.TestCase):
except GPGProblem as e:
raise AssertionError(e)
- @mock.patch('alot.crypto.check_uid_validity', mock.Mock(return_value=False))
+ @mock.patch(
+ 'alot.crypto.check_uid_validity', mock.Mock(return_value=False))
def test_signed_only_false(self):
with self.assertRaises(GPGProblem) as e:
crypto.get_key(FPR, signed_only=True)
@@ -370,7 +377,8 @@ class TestEncrypt(unittest.TestCase):
enc_file = f.name
self.addCleanup(os.unlink, enc_file)
- dec = subprocess.check_output(['gpg', '--decrypt', enc_file], stderr=DEVNULL)
+ dec = subprocess.check_output(
+ ['gpg', '--decrypt', enc_file], stderr=DEVNULL)
self.assertEqual(to_encrypt, dec)