Skip to content

Commit 2539bcd

Browse files
committed
some cleaning after using nose2pytest
1 parent f79de1d commit 2539bcd

19 files changed

+67
-72
lines changed

nibabel/tests/scriptrunner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def run_command(self, cmd, check_code=True):
135135
env['PYTHONPATH'] = self.local_module_dir + pathsep + pypath
136136
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env)
137137
stdout, stderr = proc.communicate()
138-
if proc.poll() == None:
138+
if proc.poll() is None:
139139
proc.terminate()
140140
if check_code and proc.returncode != 0:
141141
raise RuntimeError(

nibabel/tests/test_analyze.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def test_from_header(self):
512512
for check in (True, False):
513513
copy = klass.from_header(hdr, check=check)
514514
assert hdr == copy
515-
assert not hdr is copy
515+
assert hdr is not copy
516516

517517
class C(object):
518518

nibabel/tests/test_arraywriters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ def test_writer_maker():
640640
assert (aw.slope, aw.inter) == (1, 0)
641641
aw.calc_scale()
642642
slope, inter = aw.slope, aw.inter
643-
assert not (slope, inter) == (1, 0)
643+
assert (slope, inter) != (1, 0)
644644
# Should run by default
645645
aw = make_array_writer(arr, np.int16)
646646
assert (aw.slope, aw.inter) == (slope, inter)
@@ -704,7 +704,7 @@ def test_int_int_slope():
704704
aw = SlopeArrayWriter(arr, out_dt)
705705
except ScalingError:
706706
continue
707-
assert not aw.slope == 0
707+
assert aw.slope != 0
708708
arr_back_sc = round_trip(aw)
709709
# integer allclose
710710
adiff = int_abs(arr - arr_back_sc)

nibabel/tests/test_casting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_casting():
120120
# Confirm input array is not modified
121121
nans = np.isnan(farr)
122122
assert_array_equal(nans, np.isnan(farr_orig))
123-
assert_array_equal(farr[nans == False], farr_orig[nans == False])
123+
assert_array_equal(farr[nans is False], farr_orig[nans is False])
124124
# Test scalars work and return scalars
125125
assert_array_equal(float_to_int(np.float32(0), np.int16), [0])
126126
# Test scalar nan OK
@@ -155,7 +155,7 @@ def test_floor_log2():
155155
assert floor_log2(0.75) == -1
156156
assert floor_log2(0.25) == -2
157157
assert floor_log2(0.24) == -3
158-
assert floor_log2(0) == None
158+
assert floor_log2(0) is None
159159

160160

161161
def test_able_int_type():

nibabel/tests/test_deprecator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ def test_dep_func(self):
7070
dec = self.dep_func
7171
func = dec('foo')(func_no_doc)
7272
with pytest.deprecated_call():
73-
assert func() == None
73+
assert func() is None
7474
assert func.__doc__ == 'foo\n'
7575
func = dec('foo')(func_doc)
7676
with clear_and_catch_warnings(modules=[_OWN_MODULE]) as w:
7777
warnings.simplefilter('always')
78-
assert func(1) == None
78+
assert func(1) is None
7979
assert len(w) == 1
8080
assert func.__doc__ == 'A docstring\n\nfoo\n'
8181
func = dec('foo')(func_doc_long)
8282
with clear_and_catch_warnings(modules=[_OWN_MODULE]) as w:
8383
warnings.simplefilter('always')
84-
assert func(1, 2) == None
84+
assert func(1, 2) is None
8585
assert len(w) == 1
8686
assert func.__doc__ == 'A docstring\n \n foo\n \n Some text\n'
8787

@@ -90,12 +90,12 @@ def test_dep_func(self):
9090
assert func.__doc__ == 'foo\n\n* deprecated from version: 1.1\n'
9191
with clear_and_catch_warnings(modules=[_OWN_MODULE]) as w:
9292
warnings.simplefilter('always')
93-
assert func() == None
93+
assert func() is None
9494
assert len(w) == 1
9595
func = dec('foo', until='99.4')(func_no_doc)
9696
with clear_and_catch_warnings(modules=[_OWN_MODULE]) as w:
9797
warnings.simplefilter('always')
98-
assert func() == None
98+
assert func() is None
9999
assert len(w) == 1
100100
assert (func.__doc__ ==
101101
'foo\n\n* Will raise {} as of version: 99.4\n'
@@ -127,13 +127,13 @@ def test_dep_func(self):
127127
func = dec('foo', warn_class=UserWarning)(func_no_doc)
128128
with clear_and_catch_warnings(modules=[_OWN_MODULE]) as w:
129129
warnings.simplefilter('always')
130-
assert func() == None
130+
assert func() is None
131131
assert len(w) == 1
132132
assert w[0].category is UserWarning
133133

134134
func = dec('foo', error_class=CustomError)(func_no_doc)
135135
with pytest.deprecated_call():
136-
assert func() == None
136+
assert func() is None
137137

138138
func = dec('foo', until='1.8', error_class=CustomError)(func_no_doc)
139139
with pytest.raises(CustomError):
@@ -150,14 +150,14 @@ def test_deprecator_maker(self):
150150
func = dec('foo')(func_no_doc)
151151
with clear_and_catch_warnings(modules=[_OWN_MODULE]) as w:
152152
warnings.simplefilter('always')
153-
assert func() == None
153+
assert func() is None
154154
assert len(w) == 1
155155
assert w[0].category is UserWarning
156156

157157
dec = self.dep_maker(error_class=CustomError)
158158
func = dec('foo')(func_no_doc)
159159
with pytest.deprecated_call():
160-
assert func() == None
160+
assert func() is None
161161

162162
func = dec('foo', until='1.8')(func_no_doc)
163163
with pytest.raises(CustomError):

nibabel/tests/test_ecat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_subheader(self):
164164
assert self.subhdr.get_nframes() == 1
165165
assert (self.subhdr.get_nframes() ==
166166
len(self.subhdr.subheaders))
167-
assert self.subhdr._check_affines() == True
167+
assert self.subhdr._check_affines() is True
168168
assert_array_almost_equal(np.diag(self.subhdr.get_frame_affine()),
169169
np.array([2.20241979, 2.20241979, 3.125, 1.]))
170170
assert self.subhdr.get_zooms()[0] == 2.20241978764534

nibabel/tests/test_environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ def test_sys_dir():
6060
elif os.name == 'posix':
6161
assert sys_dir == r'/etc/nipy'
6262
else:
63-
assert sys_dir == None
63+
assert sys_dir is None

nibabel/tests/test_files_interface.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def test_files_spatialimages():
2929
for klass in klasses:
3030
file_map = klass.make_file_map()
3131
for key, value in file_map.items():
32-
assert value.filename == None
33-
assert value.fileobj == None
32+
assert value.filename is None
33+
assert value.fileobj is None
3434
assert value.pos == 0
3535
# If we can't create new images in memory without loading, bail here
3636
if not klass.makeable:
@@ -42,8 +42,8 @@ def test_files_spatialimages():
4242
else:
4343
img = klass(arr, aff)
4444
for key, value in img.file_map.items():
45-
assert value.filename == None
46-
assert value.fileobj == None
45+
assert value.filename is None
46+
assert value.fileobj is None
4747
assert value.pos == 0
4848

4949

nibabel/tests/test_fileslice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ def test_threshold_heuristic():
243243
# Test for default skip / read heuristic
244244
# int
245245
assert threshold_heuristic(1, 9, 1, skip_thresh=8) == 'full'
246-
assert threshold_heuristic(1, 9, 1, skip_thresh=7) == None
246+
assert threshold_heuristic(1, 9, 1, skip_thresh=7) is None
247247
assert threshold_heuristic(1, 9, 2, skip_thresh=16) == 'full'
248-
assert threshold_heuristic(1, 9, 2, skip_thresh=15) == None
248+
assert threshold_heuristic(1, 9, 2, skip_thresh=15) is None
249249
# full slice, smallest step size
250250
assert (threshold_heuristic(
251251
slice(0, 9, 1), 9, 2, skip_thresh=2) ==

nibabel/tests/test_image_load_save.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def test_analyze_detection():
274274
def wat(hdr):
275275
return nils.which_analyze_type(hdr.binaryblock)
276276
n1_hdr = Nifti1Header(b'\0' * 348, check=False)
277-
assert wat(n1_hdr) == None
277+
assert wat(n1_hdr) is None
278278
n1_hdr['sizeof_hdr'] = 540
279279
assert wat(n1_hdr) == 'nifti2'
280280
assert wat(n1_hdr.as_byteswapped()) == 'nifti2'
@@ -292,7 +292,7 @@ def wat(hdr):
292292
assert wat(n1_hdr) == 'analyze'
293293
n1_hdr['sizeof_hdr'] = 0
294294
n1_hdr['magic'] = b''
295-
assert wat(n1_hdr) == None
295+
assert wat(n1_hdr) is None
296296
n1_hdr['magic'] = 'n+1'
297297
assert wat(n1_hdr) == 'nifti1'
298298
n1_hdr['magic'] = 'ni1'

0 commit comments

Comments
 (0)