Skip to content

Commit

Permalink
Use pytest (#68)
Browse files Browse the repository at this point in the history
* Update README and requirements.txt files.

* Add missing line in README.

* Use pytest on Jenkins.

* Make Jenkins test commands the same as Travis.

* Generate test output and coverage data properly.

* Move 'checkout scm' command to start of function; remove redundant cleaning code.

Fix #65
  • Loading branch information
Hamish Ivey-Law authored and gusmith committed Mar 7, 2018
1 parent 533ed9a commit 29e7630
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
21 changes: 8 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ def configs = [

def build(python_version, compiler, label, release=false) {
try {
// The stage below is attempting to get the latest version of our application code.
// Since this is a multi-branch project the 'checkout scm' command is used. If you're working with a standard
// pipeline project then you can replace this with the regular 'git url:' pipeline command.
// The 'checkout scm' command will automatically pull down the code from the appropriate branch that triggered this build.
checkout scm

def workspace = pwd();
echo "${label}"
echo "workspace directory is ${workspace}"
Expand All @@ -25,14 +31,6 @@ def build(python_version, compiler, label, release=false) {
withEnv(["VENV=${workspace}/env"]) {
// ${workspace} contains an absolute path to job workspace (not available within a stage)

sh "test -d ${workspace}/env && rm -rf ${workspace}/env || echo 'no env, skipping cleanup'"

// The stage below is attempting to get the latest version of our application code.
// Since this is a multi-branch project the 'checkout scm' command is used. If you're working with a standard
// pipeline project then you can replace this with the regular 'git url:' pipeline command.
// The 'checkout scm' command will automatically pull down the code from the appropriate branch that triggered this build.
checkout scm

def testsError = null

clkhashPackageName = "clkhash-*-py2.py3-none-any.whl"
Expand Down Expand Up @@ -61,10 +59,7 @@ def build(python_version, compiler, label, release=false) {
CC=${compiler} ${VENV}/bin/python setup.py sdist bdist_wheel
${VENV}/bin/python ${VENV}/bin/pip install -e .
${VENV}/bin/python ${VENV}/bin/nosetests \
--with-xunit --with-coverage --cover-inclusive \
--cover-package=anonlink
${VENV}/bin/python ${VENV}/bin/pytest --cov=anonlink --junit-xml=testoutput.xml --cov-report=xml:coverage.xml
"""

if(release) {
Expand All @@ -81,7 +76,7 @@ def build(python_version, compiler, label, release=false) {
finally {

if (!release) {
junit 'nosetests.xml'
junit 'testoutput.xml'
} else {
// Code coverage only needs to be done once
sh '''#!/usr/bin/env bash
Expand Down
21 changes: 15 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Benchmark
You can run the benchmark with:

::

$ python3 -m anonlink.benchmark
Anonlink benchmark -- see README for explanation
------------------------------------------------
Expand Down Expand Up @@ -113,16 +114,24 @@ matrix, which will be approximately `#comparisons * match% / 100`.
Tests
=====

Run unit tests with nose
Run unit tests with `pytest`:

::

$ python -m nose
......................SS..............................
----------------------------------------------------------------------
Ran 54 tests in 6.615s
$ pytest
====================================== test session starts ======================================
platform linux -- Python 3.6.4, pytest-3.2.5, py-1.4.34, pluggy-0.4.0
rootdir: /home/hlaw/src/n1-anonlink, inifile:
collected 71 items

tests/test_benchmark.py ...
tests/test_bloommatcher.py ..............
tests/test_e2e.py .............ss....
tests/test_matcher.py ..x.....x......x....x..
tests/test_similarity.py .........
tests/test_util.py ...

OK (SKIP=2)
======================== 65 passed, 2 skipped, 4 xfailed in 4.01 seconds ========================

To enable slightly larger tests add the following environment variables:

Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
bitarray==0.8.1
networkx==1.11
cffi>=1.7
nose==1.3.7
clkhash==0.8.0
pytest>=3.4
pytest-cov>=2.5
clkhash==0.8.0

0 comments on commit 29e7630

Please sign in to comment.