Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pytest #68

Merged
merged 6 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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