CI unit tests should now use TOX and test both libssl 0.9.8 and libssl 1.0.0

This commit is contained in:
Michael Greene
2014-05-08 17:36:55 -07:00
parent 212e346e33
commit 5dbd94ad0e
7 changed files with 75 additions and 39 deletions

View File

@@ -4,24 +4,35 @@ python:
- "3.3"
- "3.2"
- "2.7"
# install pgpdump - it's needed for testing
before_install:
- sudo apt-get update -qq
- sudo apt-get install gnupg pgpdump -qq
# command to install dependencies
env:
matrix:
# test all versions against libssl 0.9.8
- LIBSSL=0.9.8
# test all versions against libssl 1.0.0
- LIBSSL=1.0.0
matrix:
include:
# add a pep8 test for python 2.7
- python: 2.7
env: TOXENV=pep8
# add a py3pep8 test for python 3.x
- python: 3.4
env: TOXENV=py3pep8
# install requirements
install:
- pip install -r requirements.txt
- pip install -r requirements-test.txt
- pip install python-coveralls
- pip install .
# run pep8 against the project with some errors disabled
# install dependencies
- pip install -r requirements-test.txt python-coveralls
# remove the current version of libssl, first
- sudo dpkg --remove --force-depends libssl[01]\*
# make sure gnupg, pgpdump, and the requested version of libssl are installed
- sudo apt-get update
- sudo apt-get install -y gnupg pgpdump libssl${LIBSSL}
# set TOXENV if it isn't yet
before_script:
- pep8 --ignore=E201,E202,E501,E265,E221,E251 setup.py
- pep8 --ignore=E201,E202,E501,E265 pgpy
- if [[ -z "$TOXENV" ]]; then TOXENV=py${TRAVIS_PYTHON_VERSION//.}; fi
# use setup.py to invoke testing via coveralls
script:
PYTHONPATH=. py.test -vv --cov pgpy --cov-report term-missing tests/
- tox
# and report coverage to coveralls
after_success:
coveralls

View File

@@ -1,3 +1,4 @@
-r requirements.txt
tox
pytest
pytest-cov
pep8

View File

@@ -2,7 +2,10 @@
from distutils.core import setup
from pip.req import parse_requirements
import pgpy._author
# this is dirty
import sys
sys.path.append('pgpy')
import _author
# long_description is the contents of README.rst
with open('README.rst') as readme:
@@ -15,12 +18,12 @@ test_reqs = parse_requirements('requirements-test.txt')
##TODO: fill in blank fields
setup(
name = 'PGPy',
version = pgpy._author.__version__,
version = _author.__version__,
description = 'Pretty Good Privacy for Python',
long_description = long_desc,
author = pgpy._author.__author__,
author = _author.__author__,
author_email = "mgreene@securityinnovation.com",
license = pgpy._author.__license__,
license = _author.__license__,
url = "https://github.com/Commod0re/PGPy",
download_url = "https://github.com/Commod0re/PGPy/archive/0.1.0.tar.gz",

View File

@@ -12,7 +12,7 @@ tf = TestFiles()
import pgpy
from pgpy.pgpdump import PGPDumpFormat
from pgpy.packet.types import PubKeyAlgo
from pgpy.packet.pftypes import PubKeyAlgo
from pgpy.errors import PGPError, PGPKeyDecryptionError
keys = [

View File

@@ -8,7 +8,7 @@ try:
except:
from conftest import TestFiles
from pgpy.pgp import PGPLoad, PGPKey
from pgpy.pgp import pgpload, PGPKey
from pgpy.pgpdump import PGPDumpFormat
from pgpy.packet.fields import Header
@@ -27,7 +27,7 @@ def load_enc_key(request):
class TestPGPKey:
def test_parse(self, load_key, pgpdump):
p = PGPLoad(load_key)
p = pgpload(load_key)
k = p[0]
assert len(p) == 1
@@ -35,17 +35,17 @@ class TestPGPKey:
assert '\n'.join(PGPDumpFormat(k).out) + '\n' == pgpdump.decode()
def test_crc24(self, load_key):
k = PGPLoad(load_key)[0]
k = pgpload(load_key)[0]
k.crc == k.crc24()
def test_keyid(self, load_key):
k = PGPLoad(load_key)[0]
k = pgpload(load_key)[0]
spkt = [pkt.unhashed_subpackets for pkt in k.packets if pkt.header.tag == Header.Tag.Signature][0]
assert k.keyid == spkt.Issuer.payload.decode()
assert k.keyid == spkt.issuer.payload.decode()
def test_fingerprint(self, load_key):
k = PGPLoad(load_key)[0]
k = pgpload(load_key)[0]
kfp = [ k.fingerprint[i:(i + 4)] for i in range(0, len(k.fingerprint), 4)]
kfp[4] += ' '
kfp = ' '.join(kfp)
@@ -58,17 +58,17 @@ class TestPGPKey:
assert kfp == re.search(r'Key fingerprint = ([0-9A-F ]*)', fp.decode()).group(1)
def test_str(self, load_key):
k = PGPLoad(load_key)[0]
k = pgpload(load_key)[0]
assert str(k) == k.bytes.decode()
def test_bytes(self, load_key):
k = PGPLoad(load_key)[0]
k = pgpload(load_key)[0]
assert k.__bytes__() == k.data
def test_decrypt_keymaterial(self, load_enc_key):
k = PGPLoad(load_enc_key)[0]
k = pgpload(load_enc_key)[0]
try:
k.decrypt_keymaterial("QwertyUiop")

View File

@@ -6,7 +6,7 @@ try:
except:
from conftest import TestFiles
from pgpy.pgp import PGPLoad, PGPSignature
from pgpy.pgp import pgpload, PGPSignature
from pgpy.pgpdump import PGPDumpFormat
tf = TestFiles()
@@ -19,7 +19,7 @@ def pgpsig(request):
class TestPGPSignature:
def test_parse(self, pgpsig, pgpdump):
p = PGPLoad(pgpsig)
p = pgpload(pgpsig)
sig = p[0]
assert len(p) == 1
@@ -27,16 +27,16 @@ class TestPGPSignature:
assert '\n'.join(PGPDumpFormat(sig).out) + '\n' == pgpdump.decode()
def test_crc24(self, pgpsig):
sig = PGPLoad(pgpsig)[0]
sig = pgpload(pgpsig)[0]
assert sig.crc == sig.crc24()
def test_str(self, pgpsig):
sig = PGPLoad(pgpsig)[0]
sig = pgpload(pgpsig)[0]
assert str(sig) == sig.bytes.decode()
def test_bytes(self, pgpsig):
sig = PGPLoad(pgpsig)[0]
sig = pgpload(pgpsig)[0]
assert sig.__bytes__() == sig.data

29
tox.ini
View File

@@ -1,9 +1,30 @@
[tox]
envlist = py27,py32,py33,py34
envlist = py27, py32, py33, py34, pep8, py3pep8
skipsdist = True
;[pytest]
[testenv]
commands=py.test
setenv = PYTHONPATH=.
deps = -rrequirements-test.txt
commands =
py.test -vv --cov pgpy --cov-report term-missing tests/
[pytest]
norecursedirs = testdata
[testenv:pep8]
basepython = python2.7
deps =
flake8
pep8-naming
skipsdist = True
commands =
flake8 --ignore=E201,E202,E221,E251,E265,E501 setup.py
flake8 --ignore=E201,E202,E501,E265 pgpy
[testenv:py3pep8]
basepython = python3.4
deps =
flake8
pep8-naming
commands =
flake8 --ignore=E201,E202,E221,E251,E265,E501 setup.py
flake8 --ignore=E201,E202,E501,E265 pgpy