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

TEST: Convert remainder of nibabel.tests to pytest #876

Merged
merged 79 commits into from
Feb 6, 2020
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
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
f79de1d
ignoring tests that use needs_nibabel_data
djarecka Feb 6, 2020
2539bcd
some cleaning after using nose2pytest
djarecka 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
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
Prev Previous commit
Next Next commit
small edits: suggestions from reviews
djarecka committed Feb 5, 2020
commit dd42dd8aa3645318f7a91fa8f594abed11429d4a
23 changes: 11 additions & 12 deletions nibabel/tests/test_spaces.py
Original file line number Diff line number Diff line change
@@ -76,15 +76,7 @@ def get_outspace_params():
)


@pytest.mark.parametrize("arg_tuple", [
# Enforce number of axes
((2, 3, 4, 5), np.eye(4)),
((2, 3, 4, 5, 6), np.eye(4)),
# Voxel sizes must be positive
((2, 3, 4), np.eye(4), [-1, 1, 1]),
((2, 3, 4), np.eye(4), [1, 0, 1])
])
def test_vox2out_vox(arg_tuple):
def test_vox2out_vox():
# Test world space bounding box
# Test basic case, identity, no voxel sizes passed
shape, aff = vox2out_vox(((2, 3, 4), np.eye(4)))
@@ -101,7 +93,14 @@ def test_vox2out_vox(arg_tuple):
assert isinstance(shape[0], int)
# Enforce number of axes
with pytest.raises(ValueError):
vox2out_vox(arg_tuple)
vox2out_vox(((2, 3, 4, 5), np.eye(4)))
with pytest.raises(ValueError):
vox2out_vox(((2, 3, 4, 5, 6), np.eye(4)))
# Voxel sizes must be positive
with pytest.raises(ValueError):
vox2out_vox(((2, 3, 4), np.eye(4), [-1, 1, 1]))
with pytest.raises(ValueError):
vox2out_vox(((2, 3, 4), np.eye(4), [1, 0, 1]))


def test_slice2volume():
@@ -121,6 +120,6 @@ def test_slice2volume():
[0, -1],
[0, 3]
])
def test_slice2volume_exception(args):
def test_slice2volume_exception(index, axis):
with pytest.raises(ValueError):
slice2volume(*args)
slice2volume(index, axis)
16 changes: 6 additions & 10 deletions nibabel/tests/test_spatialimages.py
Original file line number Diff line number Diff line change
@@ -173,18 +173,15 @@ class CHeader(SpatialHeader):
fobj = BytesIO()
data = np.arange(6).reshape((1, 2, 3))
hdr.data_to_fileobj(data, fobj)
assert (fobj.getvalue() ==
data.astype(np.int32).tostring(order=order))
assert fobj.getvalue() == data.astype(np.int32).tostring(order=order)
# data_to_fileobj accepts kwarg 'rescale', but no effect in this case
fobj.seek(0)
hdr.data_to_fileobj(data, fobj, rescale=True)
assert (fobj.getvalue() ==
data.astype(np.int32).tostring(order=order))
assert fobj.getvalue() == data.astype(np.int32).tostring(order=order)
# data_to_fileobj can be a list
fobj.seek(0)
hdr.data_to_fileobj(data.tolist(), fobj, rescale=True)
assert (fobj.getvalue() ==
data.astype(np.int32).tostring(order=order))
assert fobj.getvalue() == data.astype(np.int32).tostring(order=order)
# Read data back again
fobj.seek(0)
data2 = hdr.data_from_fileobj(fobj)
@@ -464,8 +461,8 @@ def test_slicer(self):
img.slicer[:, :, :, None]
else:
# Reorder non-spatial axes
assert (img.slicer[:, :, :, None].shape ==
img.shape[:3] + (1,) + img.shape[3:])
assert (img.slicer[:, :, :, None].shape
== img.shape[:3] + (1,) + img.shape[3:])
# 4D to 3D using ellipsis or slices
assert img.slicer[..., 0].shape == img.shape[:-1]
assert img.slicer[:, :, :, 0].shape == img.shape[:-1]
@@ -480,8 +477,7 @@ def test_slicer(self):
with pytest.raises(ValueError):
img.slicer[:, :, :, :, None]
else:
assert (img.slicer[:, :, :, :, None].shape ==
img.shape + (1,))
assert img.slicer[:, :, :, :, None].shape == img.shape + (1,)

# Crop by one voxel in each dimension
sliced_i = img.slicer[1:]