Skip to content

TEST: Drop nose for pytest #865

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

Merged
merged 246 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
5f8d68d
converting tests with tests/test_a*.py and test_wrapstruct (for some …
djarecka Nov 11, 2019
d65e325
converting test_b* and test_c*
djarecka Nov 12, 2019
5f07260
updating travis
djarecka Nov 12, 2019
16187e2
adding converted test_d*
djarecka Nov 12, 2019
4ee404b
converting more tests to pytest
djarecka Nov 15, 2019
50de669
fixing interaction between fixtures
djarecka Nov 15, 2019
def8ceb
moving test_helpers to testing/helpers.py (it contains no tests, but …
djarecka Nov 15, 2019
629dc57
adding new tests to travis
djarecka Nov 15, 2019
51cc6aa
adding more tests
djarecka Nov 15, 2019
ab2f5dc
converting more tests
djarecka Nov 16, 2019
1afb4fd
converting more tests to pytest
djarecka Dec 1, 2019
152abea
converting test to pytest, TODO: some tests are failing on osx
djarecka Dec 1, 2019
2ebef26
adding pytestmark to test that has not been changed to pytest
djarecka Dec 1, 2019
d68ba9d
fixing test_wrapstruct: removing setUpClass and adding self.header_cl…
djarecka Dec 1, 2019
4f2aa9a
changing travis command after fixes in test_wrapstruct
djarecka Dec 1, 2019
e211a47
MNT: Separate out pytest and nose jobs
effigies Jan 25, 2020
df6a28e
TEST: Fix tests broken in the rebase
effigies Jan 25, 2020
bfb63fc
CI: Add CHECK_TYPE to Azure
effigies Jan 25, 2020
75298a4
CI: Default to nose for Windows for now
effigies Jan 25, 2020
77402be
RF: Avoid running data script code on doctest
effigies Jan 25, 2020
62132ad
TEST: Doctests not ready
effigies Jan 25, 2020
765bec8
CI: Try alternative CHECK_TYPE test
effigies Jan 25, 2020
f908ca4
PIN: Avoid pytest 5.3.4 (pytest-dev/pytest#6517)
effigies Jan 25, 2020
60479c4
TEST: Add BaseTestCase class to skip TestCases starting with ``_``
effigies Feb 4, 2020
9d1795a
TMP: Skip failing streamlines modules
effigies Feb 4, 2020
f2ff7fe
CI: Skip converted tests in nose
effigies Feb 4, 2020
4ee9e34
Merge pull request #871 from effigies/test/base_test_case
effigies Feb 4, 2020
01b1b7e
TEST: pytest conversion #864 #865
robbisg Feb 4, 2020
ade7bde
TEST: test_tractogram to pytest #865 #864
robbisg Feb 4, 2020
083a89f
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
a12438c
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
a44ed46
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
68d5f98
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
312baa2
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
d2a5878
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
cffd3bf
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
b463079
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
b3fa3fb
Update nibabel/streamlines/tests/test_array_sequence.py
robbisg Feb 4, 2020
6e864f5
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
cb681cd
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
8b01cd4
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
c1176ec
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
d643c7f
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
8326522
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
745108a
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
c758df7
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
d168423
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
1ad759b
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
7bc83a7
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
bfa7a3d
Update nibabel/streamlines/tests/test_tractogram.py
robbisg Feb 4, 2020
4fa17af
Update test_array_sequence.py
robbisg Feb 4, 2020
51016a7
Update test_tractogram.py
robbisg Feb 4, 2020
bc0c67b
make sure cov is installed
anibalsolon Feb 4, 2020
ab2e0b8
TEST: Fix import/indentation errors
effigies Feb 4, 2020
5ec71fb
ENH: Use generic unittest.SkipTest in missing optional_package
effigies Feb 4, 2020
f2a96be
TEST: Cleanup test_array_sequence
effigies Feb 4, 2020
3b6f32a
CI: Skip more nose tests
effigies Feb 4, 2020
49909dc
TEST: Un-skip tractogram tests, style cleanups
effigies Feb 4, 2020
8fe1c2c
TEST: Fix optpkg test
effigies Feb 4, 2020
4fbcb79
TEST: Style updates to test_analyze
effigies Feb 4, 2020
24cf57d
TEST: test_trk to pytest
robbisg Feb 4, 2020
3a2b0d1
TEST: test_tck to pytest
robbisg Feb 4, 2020
d79af8b
pytest port
anibalsolon Feb 4, 2020
4d8325e
Merge pull request #872 from effigies/test/cleanups
effigies Feb 4, 2020
5695644
drop the nose
anibalsolon Feb 4, 2020
636dc55
CI: Give up trying to deselect streamlines
effigies Feb 4, 2020
85ac452
changed nosetools assert_true to assert in test_io.py
orduek Feb 4, 2020
62d53c3
finish porting gifti module tests to pytest
anibalsolon Feb 4, 2020
325080e
TEST: Style cleanup
effigies Feb 4, 2020
5f695b8
TEST: Simplify data/environment fixtures
effigies Feb 4, 2020
b985ef3
Merge remote-tracking branch 'upstream/pytest' into pytest
anibalsolon Feb 4, 2020
b66ec38
make sure cov is installed
anibalsolon Feb 4, 2020
2bc5308
changed nosetools assertion to pytest in test_mghformat.py
orduek Feb 4, 2020
f3be7b2
TEST: Simplify, reformat test_data
effigies Feb 4, 2020
92c758a
STY: Remove unused pkgutil import
effigies Feb 4, 2020
0011c11
Merge pull request #874 from robbisg/test_streamline
effigies Feb 4, 2020
1e7bdd0
test script condition
anibalsolon Feb 4, 2020
4a7a5ad
Merge branch 'pytest' into pytest
anibalsolon Feb 4, 2020
2ef9ad4
reintroduce nosetests into matrix
anibalsolon Feb 4, 2020
6817eb6
remove unnecessary dependency
anibalsolon Feb 4, 2020
9e5ef4d
Merge branch 'pytest' of github.com:anibalsolon/nibabel into pytest
anibalsolon Feb 4, 2020
2d0dc89
pytest is already tested
anibalsolon Feb 4, 2020
1725985
nose test inclusions
anibalsolon Feb 4, 2020
dba6f59
changed from numpy raises to pytest.raises and skipif
orduek Feb 4, 2020
b2676d8
windows breaklines..?
anibalsolon Feb 4, 2020
406e6dc
Changed test_mghformat.py to pytest
orduek Feb 4, 2020
ebf9471
Merge pull request #873 from anibalsolon/pytest
effigies Feb 4, 2020
fe61612
Merge pull request #875 from anibalsolon/pytest-port
effigies Feb 4, 2020
e1bb16d
small fixes
orduek Feb 4, 2020
ee4b703
Merge pull request #878 from effigies/test/cleanups2
effigies Feb 5, 2020
e763c89
TEST: Refactor NetCDF tests to be more pytest friendly
effigies Feb 5, 2020
61f6ecf
CI: Resolve Travis warnings, remove redundant job
effigies Feb 5, 2020
fb2a828
Merge pull request #879 from effigies/test/refactor_netcdf_tests
effigies Feb 5, 2020
a411f33
TEST: Use skipif mark instead of TestMinc2API.__init__
effigies Feb 5, 2020
e1da57c
TEST: Use standard syntax when possible
effigies Feb 5, 2020
dc9d82e
TEST: Use relative imports in gifti tests
effigies Feb 5, 2020
42beb1a
TEST: Simplify giftiio deprecation tests
effigies Feb 5, 2020
5d0f645
TEST: Combine imports
effigies Feb 5, 2020
979b439
TEST: Skip giftiio tests in nose
effigies Feb 5, 2020
5fdeed9
converting more tests from nibabel.tests
djarecka Feb 4, 2020
1a435fa
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
d85e79c
adding todo
djarecka Feb 4, 2020
9e6cac1
converting more tests nibabel.tests.test_s*
djarecka Feb 4, 2020
393f630
converting more tests nibabel.tests.test_t*
djarecka Feb 4, 2020
7aaa2d0
converting test_volumeutils
djarecka Feb 4, 2020
4ee8855
converting nibabel_data
djarecka Feb 4, 2020
a170497
removing todos
djarecka Feb 4, 2020
ff3cb80
Apply suggestions from code review
djarecka Feb 5, 2020
e87d3a5
Apply suggestions from code review
djarecka Feb 5, 2020
f2931ab
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
af8b386
adding todo
djarecka Feb 4, 2020
06210d5
removing todos
djarecka Feb 4, 2020
dd42dd8
small edits: suggestions from reviews
djarecka Feb 5, 2020
e55940d
ignoring tests with pytest.mark.parametrize
djarecka Feb 5, 2020
1e2caf4
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
b1fe921
adding todo
djarecka Feb 4, 2020
31c1698
converting more tests nibabel.tests.test_s*
djarecka Feb 4, 2020
e099c29
removing todos
djarecka Feb 4, 2020
264d1fa
Apply suggestions from code review
djarecka Feb 5, 2020
dd0c521
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
159956e
adding todo
djarecka Feb 4, 2020
e0da084
removing todos
djarecka Feb 4, 2020
0519f36
small edits: suggestions from reviews
djarecka Feb 5, 2020
f4f48ef
applying suggestions from 865
djarecka Feb 5, 2020
c5ccb2e
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
5122e2d
adding todo
djarecka Feb 4, 2020
a67a9c1
converting more tests nibabel.tests.test_s*
djarecka Feb 4, 2020
7013d72
removing todos
djarecka Feb 4, 2020
857bed6
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
1a24525
adding todo
djarecka Feb 4, 2020
fd2ddde
removing todos
djarecka Feb 4, 2020
920b30f
small edits: suggestions from reviews
djarecka Feb 5, 2020
f331d20
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
9751784
adding todo
djarecka Feb 4, 2020
29da7b0
converting more tests nibabel.tests.test_s*
djarecka Feb 4, 2020
f42da04
removing todos
djarecka Feb 4, 2020
dff77ba
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
61bc714
adding todo
djarecka Feb 4, 2020
338b4c3
removing todos
djarecka Feb 4, 2020
2d799c4
small edits: suggestions from reviews
djarecka Feb 5, 2020
436404f
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
831e553
adding todo
djarecka Feb 4, 2020
099e5cf
converting more tests nibabel.tests.test_s*
djarecka Feb 4, 2020
91be3bf
converting nibabel_data
djarecka Feb 4, 2020
4becc96
removing todos
djarecka Feb 4, 2020
ddb21c3
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
5ca8a74
adding todo
djarecka Feb 4, 2020
9373292
removing todos
djarecka Feb 4, 2020
20dcc69
small edits: suggestions from reviews
djarecka Feb 5, 2020
f6f5e04
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
13bacaf
adding todo
djarecka Feb 4, 2020
525b99d
converting more tests nibabel.tests.test_s*
djarecka Feb 4, 2020
82c39a1
removing todos
djarecka Feb 4, 2020
ff899a3
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
9daf10f
adding todo
djarecka Feb 4, 2020
b1d8cfb
removing todos
djarecka Feb 4, 2020
75f2ce6
small edits: suggestions from reviews
djarecka Feb 5, 2020
683a3ee
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
39c011e
adding todo
djarecka Feb 4, 2020
d5e5907
converting more tests nibabel.tests.test_s*
djarecka Feb 4, 2020
f7b49f3
removing todos
djarecka Feb 4, 2020
cdf6e18
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
8ba8134
adding todo
djarecka Feb 4, 2020
e860669
removing todos
djarecka Feb 4, 2020
32c1c17
small edits: suggestions from reviews
djarecka Feb 5, 2020
8a9f53d
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
50e7d98
adding todo
djarecka Feb 4, 2020
d4f2044
converting more tests nibabel.tests.test_s*
djarecka Feb 4, 2020
547ba92
removing todos
djarecka Feb 4, 2020
d8a15af
converting nibabel/tests/test_scripts.py
djarecka Feb 4, 2020
4e32787
adding todo
djarecka Feb 4, 2020
59af0aa
removing todos
djarecka Feb 4, 2020
a21c083
small edits: suggestions from reviews
djarecka Feb 5, 2020
8d92977
fixes to assert numpy
orduek Feb 5, 2020
ae39e06
changed nosetools assert_true to assert in test_io.py
orduek Feb 4, 2020
665b28a
changed nosetools assertion to pytest in test_mghformat.py
orduek Feb 4, 2020
441e4fe
changed from numpy raises to pytest.raises and skipif
orduek Feb 4, 2020
f99d926
Changed test_mghformat.py to pytest
orduek Feb 4, 2020
6e1e1c1
small fixes
orduek Feb 4, 2020
d27b124
fixes to assert numpy
orduek Feb 5, 2020
6890a62
Update nibabel/freesurfer/tests/test_io.py
orduek Feb 5, 2020
b7e8abb
Update nibabel/freesurfer/tests/test_io.py
orduek Feb 5, 2020
5dbe408
Update nibabel/freesurfer/tests/test_io.py
orduek Feb 5, 2020
24d96e4
Update nibabel/freesurfer/tests/test_io.py
orduek Feb 5, 2020
e8965c1
Update nibabel/freesurfer/tests/test_io.py
orduek Feb 5, 2020
bbc36d7
Update nibabel/freesurfer/tests/test_io.py
orduek Feb 5, 2020
e626a38
Update nibabel/freesurfer/tests/test_io.py
orduek Feb 5, 2020
2fb977b
Update nibabel/freesurfer/tests/test_io.py
orduek Feb 5, 2020
30a4639
added test_io to Ignore list in azure and travis
orduek Feb 5, 2020
1987f79
changes
orduek Feb 5, 2020
165da32
Update nibabel/freesurfer/tests/test_mghformat.py
orduek Feb 5, 2020
54fc107
Update nibabel/freesurfer/tests/test_mghformat.py
orduek Feb 5, 2020
27ef400
fixed style and convetion in test_io.py
orduek Feb 5, 2020
a3a2517
Merge branch 'test/pytest_freesurfer' of https://github.com/orduek/ni…
orduek Feb 5, 2020
fdd26a2
added more changes to style
orduek Feb 5, 2020
f79de1d
ignoring tests that use needs_nibabel_data
djarecka Feb 6, 2020
2539bcd
some cleaning after using nose2pytest
djarecka Feb 6, 2020
e3f171b
MNT: CI YAML formatting, extraneous .coveragerc
effigies Feb 6, 2020
eaab253
TEST: Style and formatting
effigies Feb 6, 2020
51f2485
CI: Restore import-only test
effigies Feb 6, 2020
a9bbe82
small cleaning after review
djarecka Feb 6, 2020
19b55b9
small edit
djarecka Feb 6, 2020
6838af6
Update nibabel/tests/test_image_api.py
djarecka Feb 6, 2020
6dd27a3
Merge pull request #1 from effigies/test/pytest_freesurfer
orduek Feb 6, 2020
5f4436f
Merge pull request #876 from djarecka/pytest_updates
effigies Feb 6, 2020
5064f9a
Update nibabel/freesurfer/tests/test_mghformat.py
orduek Feb 6, 2020
27f0f03
Merge branch 'pytest' into test/pytest_freesurfer
orduek Feb 6, 2020
baab901
Merge pull request #881 from orduek/test/pytest_freesurfer
effigies Feb 7, 2020
d9c385a
CI: Enable doctests
effigies Feb 7, 2020
0a49449
TEST: Use numpy 1.13 legacy print settings
effigies Feb 7, 2020
afa0f2e
Merge pull request #882 from effigies/test/doctest_modules
effigies Feb 7, 2020
40d2471
TEST: Convert nibabel.nicom to unittest/pytest
effigies Feb 7, 2020
a23c63a
TEST: Use vanilla unittest.skip* over pytest
effigies Feb 7, 2020
2542320
RF: Remove unused pieces of testing_pytest and switch to unittest skip
effigies Feb 7, 2020
a223c07
CI: Only ignore files that use fixtures
effigies Feb 8, 2020
328c236
Merge pull request #883 from effigies/test/vanilla_unittest
effigies Feb 8, 2020
78f8e71
Merge pull request #884 from effigies/test/dicom_pytest
effigies Feb 8, 2020
b2f40bd
TEST: De-indent tests, cleanup style
effigies Feb 9, 2020
8ed033c
TEST/STY: Cleaner line breaks and alignment for test_fileslice
effigies Feb 9, 2020
6be3e94
TEST/STY: Alignment in fileutils, floating tests
effigies Feb 9, 2020
84df042
TEST: cmdline module to pytest
Feb 10, 2020
103db6b
TEST: cifti2 tests to pytest
Feb 10, 2020
c7a2d77
TEST: style fixed
Feb 10, 2020
3b6896e
TEST: fixed comments
robbisg Feb 10, 2020
f8db80a
TEST/RF: Reduce redundancy in test_removalschedule, test failure case
effigies Feb 11, 2020
d5ef496
Merge remote-tracking branch 'upstream/master' into pytest
effigies Feb 12, 2020
8db1cd9
changing testing_pytest back to testing
djarecka Feb 17, 2020
0117212
TEST: Remove last imports of nose
effigies Feb 18, 2020
c9d9eba
MNT: Purge nose from requirements, CI
effigies Feb 18, 2020
1c6ea64
RF: Remove nose test state code
effigies Feb 18, 2020
ff922aa
RF: Reimplement nibabel.test() and nibabel.bench()
effigies Feb 18, 2020
6dc8f0f
DOC: Replace nose with pytest in the docs
effigies Feb 18, 2020
0079255
DOC: Update benchmark docstrings
effigies Feb 18, 2020
154b941
TEST: Final few assert_raises
effigies Feb 18, 2020
9e512bc
Merge remote-tracking branch 'upstream/master' into pytest
effigies Feb 18, 2020
3a38200
Merge pull request #891 from effigies/test/final_nose_purge
effigies Feb 19, 2020
b190eeb
Merge remote-tracking branch 'upstream/master' into pytest
effigies Feb 19, 2020
22d8c65
FIX: Return pytest.main results from nibabel.test/bench
effigies Feb 19, 2020
49be50a
TEST: Might as well test the testers. Found a bug.
effigies Feb 20, 2020
c049a4e
CI: Install test requirements through extra dependencies
effigies Feb 20, 2020
592b310
DOC: Specify current benchmark file
effigies Feb 20, 2020
7392e8f
TEST: Style and parameterization fixes for readability
effigies Feb 20, 2020
a7f8e11
TEST: Bad test syntax
effigies Feb 20, 2020
6061651
TEST/RF: Mock compress_ext_map, instead of fixture
effigies Feb 20, 2020
a98b023
TEST: Rename tests to ensure running
effigies Feb 20, 2020
5657d01
TEST/RF: Reparametrize tests
effigies Feb 20, 2020
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
10 changes: 6 additions & 4 deletions .azure-pipelines/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
variables:
EXTRA_WHEELS: "https://5cf40426d9f06eb7461d-6fe47d9331aba7cd62fc36c7196769e4.ssl.cf2.rackcdn.com"
DEPENDS: numpy scipy matplotlib h5py pydicom
CHECK_TYPE: test
strategy:
matrix:
${{ insert }}: ${{ parameters.matrix }}
Expand All @@ -29,19 +30,20 @@ jobs:
displayName: 'Update build tools'
- script: |
python -m pip install --find-links %EXTRA_WHEELS% %DEPENDS%
python -m pip install nose mock coverage codecov pytest
displayName: 'Install dependencies'
- script: |
python -m pip install .
python -m pip install .[$(CHECK_TYPE)]
SET NIBABEL_DATA_DIR=%CD%\\nibabel-data
displayName: 'Install nibabel'
- script: |
mkdir for_testing
cd for_testing
cp ../.coveragerc .
nosetests --with-doctest --with-coverage --cover-package nibabel nibabel
displayName: 'Nose tests'
pytest --doctest-modules --cov nibabel -v --pyargs nibabel
displayName: 'Pytest tests'
condition: and(succeeded(), eq(variables['CHECK_TYPE'], 'test'))
- script: |
python -m pip install codecov
cd for_testing
codecov
displayName: 'Upload To Codecov'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ doc/source/reference
venv/
.buildbot.patch
.vscode
for_testing/
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# for it to be on multiple physical lines, so long as you remember: - There
# can't be any leading "-"s - All newlines will be removed, so use ";"s

os: linux
dist: xenial
sudo: true
language: python

cache: pip

env:
global:
- SETUP_REQUIRES="pip setuptools>=30.3.0 wheel"
Expand All @@ -25,7 +25,7 @@ python:
- 3.7
- 3.8

matrix:
jobs:
include:
# Basic dependencies only
- python: 3.5
Expand Down Expand Up @@ -143,7 +143,7 @@ script:
mkdir for_testing
cd for_testing
cp ../.coveragerc .
nosetests --with-doctest --with-coverage --cover-package nibabel nibabel
pytest --doctest-modules --cov nibabel -v --pyargs nibabel
else
false
fi
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Requirements for running tests
-r requirements.txt
nose
pytest
2 changes: 1 addition & 1 deletion doc/source/devel/advanced_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Long-running tests
Long-running tests are not enabled by default, and can be resource-intensive. To run these tests:

* Set environment variable ``NIPY_EXTRA_TESTS=slow``;
* Run ``nosetests``.
* Run ``pytest nibabel``.

Note that some tests may require a machine with >4GB of RAM.

Expand Down
2 changes: 1 addition & 1 deletion doc/source/devel/make_release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Release checklist

* Make sure all tests pass (from the nibabel root directory)::

nosetests --with-doctest nibabel
pytest --doctest-modules nibabel

* Make sure you are set up to use the ``try_branch.py`` - see
https://github.com/nipy/nibotmi/blob/master/install.rst#trying-a-set-of-changes-on-the-buildbots
Expand Down
4 changes: 2 additions & 2 deletions doc/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Requirements
* h5py_ (optional, for MINC2 support)
* PyDICOM_ 0.9.9 or greater (optional, for DICOM support)
* `Python Imaging Library`_ (optional, for PNG conversion in DICOMFS)
* nose_ 0.11 or greater and pytest_ (optional, to run the tests)
* pytest_ (optional, to run the tests)
* sphinx_ (optional, to build the documentation)

Get the development sources
Expand Down Expand Up @@ -128,7 +128,7 @@ module to see if everything is fine. It should look something like this::
>>>


To run the nibabel test suite, from the terminal run ``nosetests nibabel`` or
To run the nibabel test suite, from the terminal run ``pytest nibabel`` or
``python -c "import nibabel; nibabel.test()``.

To run an extended test suite that validates ``nibabel`` for long-running and
Expand Down
121 changes: 93 additions & 28 deletions nibabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,6 @@
For more detailed information see the :ref:`manual`.
"""

# Package-wide test setup and teardown
_test_states = {
# Numpy changed print options in 1.14; we can update docstrings and remove
# these when our minimum for building docs exceeds that
'legacy_printopt': None,
}

def setup_package():
""" Set numpy print style to legacy="1.13" for newer versions of numpy """
import numpy as np
from distutils.version import LooseVersion
if LooseVersion(np.__version__) >= LooseVersion('1.14'):
if _test_states.get('legacy_printopt') is None:
_test_states['legacy_printopt'] = np.get_printoptions().get('legacy')
np.set_printoptions(legacy="1.13")

def teardown_package():
""" Reset print options when tests finish """
import numpy as np
if _test_states.get('legacy_printopt') is not None:
np.set_printoptions(legacy=_test_states.pop('legacy_printopt'))


# module imports
from . import analyze as ana
from . import spm99analyze as spm99
Expand Down Expand Up @@ -92,13 +69,101 @@ def teardown_package():
from . import streamlines
from . import viewers

from numpy.testing import Tester
test = Tester().test
bench = Tester().bench
del Tester

from .pkg_info import get_pkg_info as _get_pkg_info


def get_info():
return _get_pkg_info(os.path.dirname(__file__))


def test(label=None, verbose=1, extra_argv=None,
doctests=False, coverage=False, raise_warnings=None,
timer=False):
"""
Run tests for nibabel using pytest

The protocol mimics the ``numpy.testing.NoseTester.test()``.
Not all features are currently implemented.

Parameters
----------
label : None
Unused.
verbose: int, optional
Verbosity value for test outputs. Positive values increase verbosity, and
negative values decrease it. Default is 1.
extra_argv : list, optional
List with any extra arguments to pass to pytest.
doctests: bool, optional
If True, run doctests in module. Default is False.
coverage: bool, optional
If True, report coverage of NumPy code. Default is False.
(This requires the
`coverage module <https://nedbatchelder.com/code/modules/coveragehtml>`_).
raise_warnings : None
Unused.
timer : False
Unused.

Returns
-------
code : ExitCode
Returns the result of running the tests as a ``pytest.ExitCode`` enum
"""
import pytest
args = []

if label is not None:
raise NotImplementedError("Labels cannot be set at present")

verbose = int(verbose)
if verbose > 0:
args.append("-" + "v" * verbose)
elif verbose < 0:
args.append("-" + "q" * -verbose)

if extra_argv:
args.extend(extra_argv)
if doctests:
args.append("--doctest-modules")
if coverage:
args.extend(["--cov", "nibabel"])
if raise_warnings is not None:
raise NotImplementedError("Warning filters are not implemented")
if timer:
raise NotImplementedError("Timing is not implemented")

args.extend(["--pyargs", "nibabel"])

return pytest.main(args=args)


def bench(label=None, verbose=1, extra_argv=None):
"""
Run benchmarks for nibabel using pytest

The protocol mimics the ``numpy.testing.NoseTester.bench()``.
Not all features are currently implemented.

Parameters
----------
label : None
Unused.
verbose: int, optional
Verbosity value for test outputs. Positive values increase verbosity, and
negative values decrease it. Default is 1.
extra_argv : list, optional
List with any extra arguments to pass to pytest.

Returns
-------
code : ExitCode
Returns the result of running the tests as a ``pytest.ExitCode`` enum
"""
from pkg_resources import resource_filename
config = resource_filename("nibabel", "benchmarks/pytest.benchmark.ini")
args = []
if extra_argv is not None:
args.extend(extra_argv)
args.extend(["-c", config])
return test(label, verbose, extra_argv=args)
8 changes: 2 additions & 6 deletions nibabel/benchmarks/bench_array_to_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
import nibabel as nib
nib.bench()

If you have doctests enabled by default in nose (with a noserc file or
environment variable), and you have a numpy version <= 1.6.1, this will also
run the doctests, let's hope they pass.
Run this benchmark with::

Run this benchmark with:

nosetests -s --match '(?:^|[\\b_\\.//-])[Bb]ench' /path/to/bench_load_save.py
pytest -c <path>/benchmarks/pytest.benchmark.ini <path>/benchmarks/bench_array_to_file.py
"""

import sys
Expand Down
8 changes: 2 additions & 6 deletions nibabel/benchmarks/bench_arrayproxy_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
import nibabel as nib
nib.bench()

If you have doctests enabled by default in nose (with a noserc file or
environment variable), and you have a numpy version <= 1.6.1, this will also
run the doctests, let's hope they pass.
Run this benchmark with::

Run this benchmark with:

nosetests -s --match '(?:^|[\\b_\\.//-])[Bb]ench' /path/to/bench_arrayproxy_slicing.py
pytest -c <path>/benchmarks/pytest.benchmark.ini <path>/benchmarks/bench_arrayproxy_slicing.py
"""

from timeit import timeit
Expand Down
8 changes: 2 additions & 6 deletions nibabel/benchmarks/bench_fileslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
import nibabel as nib
nib.bench()

If you have doctests enabled by default in nose (with a noserc file or
environment variable), and you have a numpy version <= 1.6.1, this will also
run the doctests, let's hope they pass.
Run this benchmark with::

Run this benchmark with:

nosetests -s --match '(?:^|[\\b_\\.//-])[Bb]ench' /path/to/bench_fileslice.py
pytest -c <path>/benchmarks/pytest.benchmark.ini <path>/benchmarks/bench_fileslice.py
"""

import sys
Expand Down
8 changes: 2 additions & 6 deletions nibabel/benchmarks/bench_finite_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
import nibabel as nib
nib.bench()

If you have doctests enabled by default in nose (with a noserc file or
environment variable), and you have a numpy version <= 1.6.1, this will also
run the doctests, let's hope they pass.
Run this benchmark with::

Run this benchmark with:

nosetests -s --match '(?:^|[\\b_\\.//-])[Bb]ench' /path/to/bench_finite_range
pytest -c <path>/benchmarks/pytest.benchmark.ini <path>/benchmarks/bench_finite_range.py
"""

import sys
Expand Down
8 changes: 2 additions & 6 deletions nibabel/benchmarks/bench_load_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
import nibabel as nib
nib.bench()

If you have doctests enabled by default in nose (with a noserc file or
environment variable), and you have a numpy version <= 1.6.1, this will also
run the doctests, let's hope they pass.
Run this benchmark with::

Run this benchmark with:

nosetests -s --match '(?:^|[\\b_\\.//-])[Bb]ench' /path/to/bench_load_save.py
pytest -c <path>/benchmarks/pytest.benchmark.ini <path>/benchmarks/bench_load_save.py
"""

import sys
Expand Down
8 changes: 2 additions & 6 deletions nibabel/benchmarks/bench_streamlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
import nibabel as nib
nib.bench()

If you have doctests enabled by default in nose (with a noserc file or
environment variable), and you have a numpy version <= 1.6.1, this will also run
the doctests, let's hope they pass.
Run this benchmark with::

Run this benchmark with:

nosetests -s --match '(?:^|[\\b_\\.//-])[Bb]ench' /path/to/bench_streamlines.py
pytest -c <path>/benchmarks/pytest.benchmark.ini <path>/benchmarks/bench_streamlines.py
"""

import numpy as np
Expand Down
4 changes: 4 additions & 0 deletions nibabel/benchmarks/pytest.benchmark.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
python_files = bench_*.py
python_functions = bench_*
addopts = --capture=no
Loading