Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #271 from NBISweden/feature/testnames
Browse files Browse the repository at this point in the history
Output test names
  • Loading branch information
silverdaz authored Apr 6, 2018
2 parents 734f244 + 4fef55b commit 2a0c02e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Configure tests to print the docstrings (and class+function names if no docstrings)

def pytest_itemcollected(item):
par = item.parent.obj
node = item.obj
# First line only
prefix = par.__doc__.split('\n',1)[0].strip() if par.__doc__ else par.__class__.__name__
suffix = node.__doc__.split('\n',1)[0].strip() if node.__doc__ else node.__name__
if prefix or suffix:
item._nodeid = ' | '.join((prefix, suffix))
4 changes: 3 additions & 1 deletion tests/keyserver.py → tests/test_keyserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@


class KeyserverTestCase(AioHTTPTestCase):
"""Testing keyserver by importing the routes and mocking the innerworkings."""
"""KeyServer
Testing keyserver by importing the routes and mocking the innerworkings."""

async def get_application(self):
"""Retrieve the routes to a mock server."""
Expand Down
17 changes: 11 additions & 6 deletions tests/openpgp.py → tests/test_openpgp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
'''OpenPGP
Testing that the openpgp utilities with a given set of public/private keys and a simple file to decrypt'''
import unittest
import io

Expand All @@ -16,7 +19,9 @@ def fetch_private_key(key_id):
return make_key(data)

def test_session_key():
'''Check if the session key is correctly decrypted'''
'''Retrieve the session key
Get the session key (Decrypt with PGP Private Key and passphrase).'''
name = cipher = session_key = None
output = io.BytesIO()
infile = io.BytesIO(bytes.fromhex(openpgp_data.ENC_FILE))
Expand All @@ -29,7 +34,7 @@ def test_session_key():
assert( session_key.hex().upper() == openpgp_data.SESSION_KEY )

def test_decryption():
'''Decrypt an encrypted file and match with its original'''
'''Decrypt an encrypted file and match with its original.'''
name = cipher = session_key = None
output = io.BytesIO()
infile = io.BytesIO(bytes.fromhex(openpgp_data.ENC_FILE))
Expand All @@ -44,7 +49,7 @@ def test_decryption():
assert( output.getvalue() == openpgp_data.ORG_FILE )

def test_keyid_for_pubkey():
'''Get the keyID from armored pub key'''
'''Get the keyID from armored pub key.'''
infile = io.BytesIO(openpgp_data.PGP_PUBKEY.encode())
key_id = None
for packet in iter_packets(unarmor(infile)):
Expand All @@ -56,7 +61,7 @@ def test_keyid_for_pubkey():
assert( key_id == openpgp_data.KEY_ID )

def test_keyid_for_pubkey_bin():
'''Get the keyID from binary pub key'''
'''Get the keyID from binary pub key.'''
infile = io.BytesIO(bytes.fromhex(openpgp_data.PGP_PUBKEY_BIN))
key_id = None
for packet in iter_packets(infile):
Expand All @@ -68,7 +73,7 @@ def test_keyid_for_pubkey_bin():
assert( key_id == openpgp_data.KEY_ID )

def test_keyid_for_privkey():
'''Get the keyID from armored priv key'''
'''Get the keyID from armored priv key.'''
infile = io.BytesIO(openpgp_data.PGP_PRIVKEY.encode())
key_id, data = None, None
for packet in iter_packets(unarmor(infile)):
Expand All @@ -80,7 +85,7 @@ def test_keyid_for_privkey():
assert( key_id == openpgp_data.KEY_ID )

def test_keyid_for_privkey_bin():
'''Get the keyID from binary priv key'''
'''Get the keyID from binary priv key.'''
infile = io.BytesIO(bytes.fromhex(openpgp_data.PGP_PRIVKEY_BIN))
key_id, data = None, None
for packet in iter_packets(infile):
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ deps = flake8
deps =
-rrequirements.txt
-rtests/requirements.txt
commands = pytest
# Stop after first failure
commands = pytest -x tests/

0 comments on commit 2a0c02e

Please sign in to comment.