diff --git a/.azure-pipelines/windows.yml b/.azure-pipelines/windows.yml index 0cda80d6ee..826c7ddc41 100644 --- a/.azure-pipelines/windows.yml +++ b/.azure-pipelines/windows.yml @@ -30,6 +30,7 @@ jobs: - script: | python -m pip install --find-links %EXTRA_WHEELS% %DEPENDS% python -m pip install nose mock coverage codecov + python -m pip install pytest displayName: 'Install dependencies' - script: | python -m pip install . @@ -40,6 +41,7 @@ jobs: cd for_testing cp ../.coveragerc . nosetests --with-doctest --with-coverage --cover-package nibabel nibabel + pytest -v ../nibabel/tests/test_affines.py displayName: 'Nose tests' - script: | cd for_testing diff --git a/.travis.yml b/.travis.yml index 1b81ba296c..39f1a14a45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -132,6 +132,7 @@ script: cd for_testing cp ../.coveragerc . nosetests --with-doctest --with-coverage --cover-package nibabel nibabel + pytest -v ../nibabel/tests/test_affines.py else false fi diff --git a/nibabel/tests/test_affines.py b/nibabel/tests/test_affines.py index 13b554c5a8..6fd2f59fab 100644 --- a/nibabel/tests/test_affines.py +++ b/nibabel/tests/test_affines.py @@ -10,7 +10,7 @@ from_matvec, dot_reduce, voxel_sizes, obliquity) -from nose.tools import assert_equal, assert_raises +import pytest from numpy.testing import assert_array_equal, assert_almost_equal, \ assert_array_almost_equal @@ -80,7 +80,7 @@ def test_matrix_vector(): vec = xform[:-1, -1] assert_array_equal(newmat, mat) assert_array_equal(newvec, vec) - assert_equal(newvec.shape, (M - 1,)) + assert newvec.shape == (M - 1,) assert_array_equal(from_matvec(mat, vec), xform) # Check default translation works xform_not = xform[:] @@ -126,17 +126,19 @@ def test_append_diag(): [0, 0, 0, 5, 9], [0, 0, 0, 0, 1]]) # Length of starts has to match length of steps - assert_raises(AffineError, append_diag, aff, [5, 6], [9]) + with pytest.raises(AffineError): + append_diag(aff, [5, 6], [9]) def test_dot_reduce(): # Chaining numpy dot # Error for no arguments - assert_raises(TypeError, dot_reduce) + with pytest.raises(TypeError): + dot_reduce() # Anything at all on its own, passes through - assert_equal(dot_reduce(1), 1) - assert_equal(dot_reduce(None), None) - assert_equal(dot_reduce([1, 2, 3]), [1, 2, 3]) + assert dot_reduce(1) == 1 + assert dot_reduce(None) is None + assert dot_reduce([1, 2, 3]) == [1, 2, 3] # Two or more -> dot product vec = [1, 2, 3] mat = np.arange(4, 13).reshape((3, 3)) diff --git a/setup.cfg b/setup.cfg index 5630921dd9..3b5bddae19 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,6 +33,7 @@ install_requires = numpy >=1.12 tests_require = nose >=0.11 + pytest mock test_suite = nose.collector zip_safe = False @@ -54,6 +55,7 @@ test = coverage mock nose >=0.11 + pytest all = %(dicom)s %(doc)s