Skip to content

Commit

Permalink
MAINT: A minimal infrastructure for unit-tests, with some initial tes…
Browse files Browse the repository at this point in the history
…t files
  • Loading branch information
oesteban committed Nov 1, 2019
1 parent d2d8a7d commit 4e086c8
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage:
range: "0...100"
ignore:
- "**/data"
- "**/tests"
- "setup.py"
13 changes: 13 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[run]
branch = True
omit =
*/tests/*
*/_afq/*
dmriprep/_version.py
dmriprep/conftest.py

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
raise NotImplementedError
warnings\.warn
83 changes: 79 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,91 @@
# vim ft=yaml
dist: xenial
sudo: true
language: python
sudo: false

cache:
directories:
- $HOME/.cache/pip

python:
- 3.6
- 3.7


env:
global:
- CHECK_TYPE="install"
- INSTALL_TYPE="pip"
- INSTALL_DEPENDS="pip setuptools"
matrix:
- CHECK_TYPE="style"
- CHECK_TYPE="test"
- INSTALL_TYPE="install"
- INSTALL_TYPE="develop"
- INSTALL_TYPE="sdist"
- INSTALL_TYPE="wheel"
- INSTALL_DEPENDS="pip==18.1 setuptools==30.2.1"
- INSTALL_DEPENDS="pip==10.0.1 setuptools==30.4.0"

matrix:
exclude:
- python: 3.7
env: CHECK_TYPE="style"
allow_failures:
- python: 3.6
env: INSTALL_DEPENDS="pip==10.0.1 setuptools==30.4.0"
- python: 3.7
env: INSTALL_DEPENDS="pip==10.0.1 setuptools==30.4.0"

before_install:
- python -m pip install --upgrade pip
- pip install "flake8<3.0" flake8-putty
- python -m pip install --upgrade pip virtualenv
- virtualenv --python=python /tmp/venv
- source /tmp/venv/bin/activate
- python --version
- python -m pip --version
- python -m pip install --upgrade $INSTALL_DEPENDS
- python -m pip --version
- |
if [ "$INSTALL_TYPE" == "pip" ]; then
PACKAGE="."
elif [ "$INSTALL_TYPE" == "sdist" ]; then
python setup.py sdist
PACKAGE="$( ls dist/*.tar.gz )"
elif [ "$INSTALL_TYPE" == "wheel" ]; then
python setup.py bdist_wheel
PACKAGE="$( ls dist/*.whl )"
fi
install:
- |
if [ "$INSTALL_TYPE" == "install" ]; then
python setup.py install
elif [ "$INSTALL_TYPE" == "develop" ]; then
python setup.py develop
else
python -m pip install $PACKAGE
fi
- |
INTENDED_VERSION="$(python -c 'import versioneer; print(versioneer.get_version())')"
pushd /tmp
INSTALLED_VERSION="$(python -c 'import dmriprep; print(dmriprep.__version__)')"
python -c 'import dmriprep; print(dmriprep.__file__)'
echo "Intended: $INTENDED_VERSION"
echo "Installed: $INSTALLED_VERSION"
test "$INTENDED_VERSION" == "$INSTALLED_VERSION"
popd
- if [ "$CHECK_TYPE" = "install" ]; then exit 0; fi

before_script:
- travis_retry python -m pip install "dmriprep[$CHECK_TYPE]"
script:
- flake8 dmriprep
- |
if [ "$CHECK_TYPE" == "style" ]; then
flake8 dmriprep
elif [ "$CHECK_TYPE" == "test" ]; then
pytest -n 2 -vv --doctest-modules --cov dmriprep --cov-config .coveragerc --cov-report xml:cov.xml dmriprep
else
false
fi
after_script:
- python -m pip install codecov
- codecov
21 changes: 21 additions & 0 deletions dmriprep/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""py.test configuration."""
import os
import tempfile
from pathlib import Path
import numpy as np
import nibabel as nb
import pytest


@pytest.fixture(autouse=True)
def doctest_autoimport(doctest_namespace):
"""Make available some fundamental modules to doctest modules."""
doctest_namespace['np'] = np
doctest_namespace['nb'] = nb
doctest_namespace['os'] = os
doctest_namespace['Path'] = Path
doctest_namespace['data_dir'] = Path(__file__).parent / 'data' / 'tests'
tmpdir = tempfile.TemporaryDirectory()
doctest_namespace['tmpdir'] = tmpdir.name
yield
tmpdir.cleanup()
105 changes: 105 additions & 0 deletions dmriprep/data/tests/bval
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
0
2500
2500
2500
2500
2500
2500
2500
2500
0
2500
2500
2500
2500
2500
2500
2500
2500
0
2500
2500
2500
2500
2500
2500
2500
2500
0
2500
2500
2500
2500
2500
2500
2500
2500
0
2500
2500
2500
2500
2500
2500
2500
2500
0
2500
2500
2500
2500
2500
2500
2500
2500
0
2500
2500
2500
2500
2500
2500
2500
2500
0
2500
2500
2500
2500
2500
1200
1200
1200
0
1200
1200
1200
1200
1200
1200
1200
1200
0
1200
1200
1200
1200
1200
1200
1200
1200
0
1200
1200
1200
1200
1200
1200
1200
1200
0
1200
1200
1200
1200
1200
3 changes: 3 additions & 0 deletions dmriprep/data/tests/bvec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0.000000000000000000e+00 -4.900384695298463239e-02 -7.261448803568887334e-01 6.832152467094113613e-01 -8.447360612148637760e-01 7.303634462442597508e-01 5.099678730359662182e-02 1.799958601428245167e-02 4.441819297579839287e-01 0.000000000000000000e+00 9.895082430076975744e-01 4.698200933497754805e-01 -4.118960093847884307e-01 5.519743337902043301e-01 1.229201892472143037e-01 8.483882264407188734e-01 3.411076364416253948e-01 -3.610025270265337927e-01 0.000000000000000000e+00 4.719905602831905300e-01 8.560779066344169630e-01 -7.969294748620739943e-01 -4.670873535034215651e-01 -1.300449382906106351e-02 -8.824492810552004851e-01 -1.700067153978899667e-02 4.420322695335568985e-01 0.000000000000000000e+00 -3.650675437439669935e-01 -9.770420137099036229e-01 4.061086485971938109e-01 6.271361033032277765e-01 3.539851329366184296e-01 6.582818049316773168e-01 -4.229953470767730539e-01 -2.119635454050159407e-01 0.000000000000000000e+00 -9.115607335641323639e-01 3.110841596493176264e-01 -6.788842600996385368e-01 -1.349580345758559508e-01 6.469877073503395026e-01 -9.040953870952732618e-01 7.572927502328845595e-01 -1.430136584566050473e-01 0.000000000000000000e+00 -2.330642180393236174e-01 -6.638055334638701677e-01 -1.570514427726418805e-01 8.947830414154962497e-01 -5.937515669429782594e-01 5.998632467678286125e-03 -6.652272138969456128e-01 2.770963077032987942e-01 0.000000000000000000e+00 9.622964329590593113e-01 1.330403838856942245e-01 -7.897449535633485063e-01 1.939680948723744580e-01 2.359970500553113526e-01 8.844064781865559333e-01 -4.631901786104944962e-01 -7.000430539717695799e-01 0.000000000000000000e+00 2.000220036306656346e-01 -5.496906112542929712e-01 6.697194463156821431e-01 -2.370055696963325187e-01 -9.603842305537075852e-01 -4.900384695298463239e-02 -7.261448803568887334e-01 6.832152467094113613e-01 0.000000000000000000e+00 -8.447360612148637760e-01 7.303634462442597508e-01 5.099678730359662182e-02 1.799958601428245167e-02 4.441819297579839287e-01 9.895082430076975744e-01 4.698200933497754805e-01 -4.118960093847884307e-01 0.000000000000000000e+00 5.519743337902043301e-01 1.229201892472143037e-01 8.483882264407188734e-01 3.411076364416253948e-01 -3.610025270265337927e-01 4.719905602831905300e-01 8.560779066344169630e-01 -7.969294748620739943e-01 0.000000000000000000e+00 -4.670873535034215651e-01 -1.300449382906106351e-02 -8.824492810552004851e-01 -1.700067153978899667e-02 4.420322695335568985e-01 -3.650675437439669935e-01 -9.770420137099036229e-01 4.061086485971938109e-01 0.000000000000000000e+00 6.271361033032277765e-01 3.539851329366184296e-01 6.582818049316773168e-01 -4.229953470767730539e-01 -2.119635454050159407e-01
0.000000000000000000e+00 9.190721499957731355e-01 -3.010600674757899498e-01 -2.550803629734990641e-01 5.018431984968777515e-01 6.193081825002695329e-01 -3.899754323216212543e-02 -8.709799676911119670e-01 -4.942024173433424705e-01 0.000000000000000000e+00 8.604419504414760611e-02 8.546727230086341720e-01 -3.998990382376587105e-01 -7.899632675620676947e-01 4.766904900074895868e-01 -1.410645518020534894e-01 7.882487317184774245e-01 5.290037030388820005e-01 0.000000000000000000e+00 -8.499830005099828778e-01 4.810437769756478188e-01 -1.619856649029560725e-01 9.001683472228679678e-03 -9.983449878002262912e-01 3.871971335242206380e-01 5.360211732545235863e-01 6.510475282044017042e-01 0.000000000000000000e+00 5.801073297849339283e-02 4.000172011094794977e-03 9.022413818587901035e-01 -6.141332813846600569e-01 -7.719675780425689915e-01 4.722021457868566530e-01 -3.219964580584419034e-01 7.538703454499151579e-01 0.000000000000000000e+00 1.039499082134536789e-01 -9.472562674852212927e-01 -6.318922715507681032e-01 2.859110954718133701e-01 -2.299956301245410506e-01 -3.970418901292295244e-01 -6.472502105689252883e-01 -2.840271258858449999e-01 0.000000000000000000e+00 -8.942463988289928167e-01 5.308444853453540002e-01 -7.102326392902913454e-01 2.139481238691801068e-01 -7.996654100242131524e-02 -6.878431896271101076e-01 -7.462548895746186073e-01 -2.760959600220594390e-01 0.000000000000000000e+00 -2.680825821549146504e-01 9.702945290911532128e-01 4.048692483457673186e-01 1.929682593317951778e-01 -9.519881002231204148e-01 2.721250702112480435e-01 3.071261011520989848e-01 -6.600405937448113047e-02 0.000000000000000000e+00 -9.281020968462885268e-01 -7.046034198805026794e-01 -7.266955783156729964e-01 -7.220169675981100710e-01 -2.601040624416292024e-01 9.190721499957731355e-01 -3.010600674757899498e-01 -2.550803629734990641e-01 0.000000000000000000e+00 5.018431984968777515e-01 6.193081825002695329e-01 -3.899754323216212543e-02 -8.709799676911119670e-01 -4.942024173433424705e-01 8.604419504414760611e-02 8.546727230086341720e-01 -3.998990382376587105e-01 0.000000000000000000e+00 -7.899632675620676947e-01 4.766904900074895868e-01 -1.410645518020534894e-01 7.882487317184774245e-01 5.290037030388820005e-01 -8.499830005099828778e-01 4.810437769756478188e-01 -1.619856649029560725e-01 0.000000000000000000e+00 9.001683472228679678e-03 -9.983449878002262912e-01 3.871971335242206380e-01 5.360211732545235863e-01 6.510475282044017042e-01 5.801073297849339283e-02 4.000172011094794977e-03 9.022413818587901035e-01 0.000000000000000000e+00 -6.141332813846600569e-01 -7.719675780425689915e-01 4.722021457868566530e-01 -3.219964580584419034e-01 7.538703454499151579e-01
0.000000000000000000e+00 -3.910306971146325083e-01 -6.181233279071035591e-01 -6.842155618583269927e-01 -1.859419022319108716e-01 -2.881433870114339379e-01 9.979371319409693353e-01 -4.909887073895935483e-01 7.473060845252568196e-01 0.000000000000000000e+00 -1.160596119200130588e-01 2.209154055963837848e-01 8.187932807916061817e-01 -2.669875853659139930e-01 8.704348360514119198e-01 5.102334852414700528e-01 -5.121616124871325448e-01 7.680053760564486964e-01 0.000000000000000000e+00 2.339953201403953131e-01 1.890172013480196367e-01 5.819484998365458406e-01 -8.841653543833503104e-01 -5.601935803287842047e-02 2.671360068500436835e-01 -8.440333399754065269e-01 6.170450459325896864e-01 0.000000000000000000e+00 9.291719127072475271e-01 -2.130091595907978030e-01 -1.450388030704263254e-01 4.791039768456875070e-01 -5.279778253969902302e-01 -5.862509691336821316e-01 -8.469906831537276082e-01 -6.218930435939619139e-01 0.000000000000000000e+00 3.978083025861015587e-01 -7.702083695497574656e-02 -3.739362493037773350e-01 9.487049986110169808e-01 7.269861873936580565e-01 1.580166716383331615e-01 -8.703364500694975303e-02 9.480905469710600997e-01 0.000000000000000000e+00 -3.821052845108224294e-01 5.268456568305114329e-01 6.862247754269577005e-01 3.919049745641056126e-01 8.006649917867435517e-01 -7.258345285890726029e-01 2.400820020079202227e-02 9.203198667401981670e-01 0.000000000000000000e+00 4.601417454897788889e-02 -2.020613349241370538e-01 -4.608511691046882630e-01 9.618417900372382423e-01 1.949975625457021911e-01 -3.791742706252315687e-01 8.313413356918378794e-01 -7.110437305341831271e-01 0.000000000000000000e+00 -3.140345457001449958e-01 4.487474262785045576e-01 1.529359332631333723e-01 -6.500152755384648318e-01 -1.000400240160112253e-01 -3.910306971146325083e-01 -6.181233279071035591e-01 -6.842155618583269927e-01 0.000000000000000000e+00 -1.859419022319108716e-01 -2.881433870114339379e-01 9.979371319409693353e-01 -4.909887073895935483e-01 7.473060845252568196e-01 -1.160596119200130588e-01 2.209154055963837848e-01 8.187932807916061817e-01 0.000000000000000000e+00 -2.669875853659139930e-01 8.704348360514119198e-01 5.102334852414700528e-01 -5.121616124871325448e-01 7.680053760564486964e-01 2.339953201403953131e-01 1.890172013480196367e-01 5.819484998365458406e-01 0.000000000000000000e+00 -8.841653543833503104e-01 -5.601935803287842047e-02 2.671360068500436835e-01 -8.440333399754065269e-01 6.170450459325896864e-01 9.291719127072475271e-01 -2.130091595907978030e-01 -1.450388030704263254e-01 0.000000000000000000e+00 4.791039768456875070e-01 -5.279778253969902302e-01 -5.862509691336821316e-01 -8.469906831537276082e-01 -6.218930435939619139e-01
Binary file added dmriprep/data/tests/dwi.nii.gz
Binary file not shown.
106 changes: 106 additions & 0 deletions dmriprep/data/tests/dwi.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# R A S B
0.00000000 0.00000000 0.00000000 0
0.04900000 -0.91900000 -0.39100000 2500
0.72600000 0.30100000 -0.61800000 2500
-0.68300000 0.25500000 -0.68400000 2500
0.84500000 -0.50200000 -0.18600000 2500
-0.73000000 -0.61900000 -0.28800000 2500
-0.05100000 0.03900000 0.99800000 2500
-0.01800000 0.87100000 -0.49100000 2500
-0.44400000 0.49400000 0.74700000 2500
0.00000000 0.00000000 0.00000000 0
-0.98900000 -0.08600000 -0.11600000 2500
-0.47000000 -0.85500000 0.22100000 2500
0.41200000 0.40000000 0.81900000 2500
-0.55200000 0.79000000 -0.26700000 2500
-0.12300000 -0.47700000 0.87100000 2500
-0.84800000 0.14100000 0.51000000 2500
-0.34100000 -0.78800000 -0.51200000 2500
0.36100000 -0.52900000 0.76800000 2500
0.00000000 0.00000000 0.00000000 0
-0.47200000 0.85000000 0.23400000 2500
-0.85600000 -0.48100000 0.18900000 2500
0.79700000 0.16200000 0.58200000 2500
0.46700000 -0.00900000 -0.88400000 2500
0.01300000 0.99800000 -0.05600000 2500
0.88200000 -0.38700000 0.26700000 2500
0.01700000 -0.53600000 -0.84400000 2500
-0.44200000 -0.65100000 0.61700000 2500
0.00000000 0.00000000 0.00000000 0
0.36500000 -0.05800000 0.92900000 2500
0.97700000 -0.00400000 -0.21300000 2500
-0.40600000 -0.90200000 -0.14500000 2500
-0.62700000 0.61400000 0.47900000 2500
-0.35400000 0.77200000 -0.52800000 2500
-0.65800000 -0.47200000 -0.58600000 2500
0.42300000 0.32200000 -0.84700000 2500
0.21200000 -0.75400000 -0.62200000 2500
0.00000000 0.00000000 0.00000000 0
0.91200000 -0.10400000 0.39800000 2500
-0.31100000 0.94700000 -0.07700000 2500
0.67900000 0.63200000 -0.37400000 2500
0.13500000 -0.28600000 0.94900000 2500
-0.64700000 0.23000000 0.72700000 2500
0.90400000 0.39700000 0.15800000 2500
-0.75700000 0.64700000 -0.08700000 2500
0.14300000 0.28400000 0.94800000 2500
0.00000000 0.00000000 0.00000000 0
0.23300000 0.89400000 -0.38200000 2500
0.66400000 -0.53100000 0.52700000 2500
0.15700000 0.71000000 0.68600000 2500
-0.89500000 -0.21400000 0.39200000 2500
0.59400000 0.08000000 0.80100000 2500
-0.00600000 0.68800000 -0.72600000 2500
0.66500000 0.74600000 0.02400000 2500
-0.27700000 0.27600000 0.92000000 2500
0.00000000 0.00000000 0.00000000 0
-0.96200000 0.26800000 0.04600000 2500
-0.13300000 -0.97000000 -0.20200000 2500
0.79000000 -0.40500000 -0.46100000 2500
-0.19400000 -0.19300000 0.96200000 2500
-0.23600000 0.95200000 0.19500000 2500
-0.88400000 -0.27200000 -0.37900000 2500
0.46300000 -0.30700000 0.83100000 2500
0.70000000 0.06600000 -0.71100000 2500
0.00000000 0.00000000 0.00000000 0
-0.20000000 0.92800000 -0.31400000 2500
0.55000000 0.70500000 0.44900000 2500
-0.67000000 0.72700000 0.15300000 2500
0.23700000 0.72200000 -0.65000000 2500
0.96000000 0.26000000 -0.10000000 2500
0.04900000 -0.91900000 -0.39100000 1200
0.72600000 0.30100000 -0.61800000 1200
-0.68300000 0.25500000 -0.68400000 1200
0.00000000 0.00000000 0.00000000 0
0.84500000 -0.50200000 -0.18600000 1200
-0.73000000 -0.61900000 -0.28800000 1200
-0.05100000 0.03900000 0.99800000 1200
-0.01800000 0.87100000 -0.49100000 1200
-0.44400000 0.49400000 0.74700000 1200
-0.98900000 -0.08600000 -0.11600000 1200
-0.47000000 -0.85500000 0.22100000 1200
0.41200000 0.40000000 0.81900000 1200
0.00000000 0.00000000 0.00000000 0
-0.55200000 0.79000000 -0.26700000 1200
-0.12300000 -0.47700000 0.87100000 1200
-0.84800000 0.14100000 0.51000000 1200
-0.34100000 -0.78800000 -0.51200000 1200
0.36100000 -0.52900000 0.76800000 1200
-0.47200000 0.85000000 0.23400000 1200
-0.85600000 -0.48100000 0.18900000 1200
0.79700000 0.16200000 0.58200000 1200
0.00000000 0.00000000 0.00000000 0
0.46700000 -0.00900000 -0.88400000 1200
0.01300000 0.99800000 -0.05600000 1200
0.88200000 -0.38700000 0.26700000 1200
0.01700000 -0.53600000 -0.84400000 1200
-0.44200000 -0.65100000 0.61700000 1200
0.36500000 -0.05800000 0.92900000 1200
0.97700000 -0.00400000 -0.21300000 1200
-0.40600000 -0.90200000 -0.14500000 1200
0.00000000 0.00000000 0.00000000 0
-0.62700000 0.61400000 0.47900000 1200
-0.35400000 0.77200000 -0.52800000 1200
-0.65800000 -0.47200000 -0.58600000 1200
0.42300000 0.32200000 -0.84700000 1200
0.21200000 -0.75400000 -0.62200000 1200
15 changes: 12 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ docs =
duecredit = duecredit
resmon =
sentry = sentry-sdk >=0.6.9
tests =
codecov
style =
flake8 >= 3.7.0
test =
pytest >= 4.4
pytest-xdist >= 1.28
pytest-cov
coverage
pytest
tests =
%(test)s
all =
%(datalad)s
%(doc)s
Expand Down Expand Up @@ -97,3 +102,7 @@ putty-ignore =
*/__init__.py : +F401
docs/conf.py : +E265
/^\s*\.\. _.*?: http/ : +E501

[tool:pytest]
norecursedirs = .* _*
addopts = --doctest-modules

0 comments on commit 4e086c8

Please sign in to comment.