34
34
from ..spatialimages import HeaderDataError
35
35
from .. import imageglobals
36
36
37
- from unittest import TestCase , SkipTest
37
+ from .. testing_pytest import BaseTestCase
38
38
39
39
from numpy .testing import assert_array_equal
40
40
import pytest
@@ -106,7 +106,7 @@ def log_chk(hdr, level):
106
106
return hdrc , message , raiser
107
107
108
108
109
- class _TestWrapStructBase (TestCase ):
109
+ class _TestWrapStructBase (BaseTestCase ):
110
110
''' Class implements base tests for binary headers
111
111
112
112
It serves as a base class for other binary header tests
@@ -119,8 +119,6 @@ def get_bad_bb(self):
119
119
return None
120
120
121
121
def test_general_init (self ):
122
- if not self .header_class :
123
- pytest .skip ()
124
122
hdr = self .header_class ()
125
123
# binaryblock has length given by header data dtype
126
124
binblock = hdr .binaryblock
@@ -140,8 +138,6 @@ def _set_something_into_hdr(self, hdr):
140
138
141
139
def test__eq__ (self ):
142
140
# Test equal and not equal
143
- if not self .header_class :
144
- pytest .skip ()
145
141
hdr1 = self .header_class ()
146
142
hdr2 = self .header_class ()
147
143
assert hdr1 == hdr2
@@ -158,8 +154,6 @@ def test__eq__(self):
158
154
159
155
def test_to_from_fileobj (self ):
160
156
# Successful write using write_to
161
- if not self .header_class :
162
- pytest .skip ()
163
157
hdr = self .header_class ()
164
158
str_io = BytesIO ()
165
159
hdr .write_to (str_io )
@@ -169,8 +163,6 @@ def test_to_from_fileobj(self):
169
163
assert hdr2 .binaryblock == hdr .binaryblock
170
164
171
165
def test_mappingness (self ):
172
- if not self .header_class :
173
- pytest .skip ()
174
166
hdr = self .header_class ()
175
167
with pytest .raises (ValueError ):
176
168
hdr .__setitem__ ('nonexistent key' , 0.1 )
@@ -207,16 +199,12 @@ def test_endianness_ro(self):
207
199
endianness on initialization (or occasionally byteswapping the
208
200
data) - but this is done via via the as_byteswapped method
209
201
'''
210
- if not self .header_class :
211
- pytest .skip ()
212
202
hdr = self .header_class ()
213
203
with pytest .raises (AttributeError ):
214
204
hdr .__setattr__ ('endianness' , '<' )
215
205
216
206
def test_endian_guess (self ):
217
207
# Check guesses of endian
218
- if not self .header_class :
219
- pytest .skip ()
220
208
eh = self .header_class ()
221
209
assert eh .endianness == native_code
222
210
hdr_data = eh .structarr .copy ()
@@ -231,17 +219,13 @@ def test_binblock_is_file(self):
231
219
# strings following. More generally, there may be other perhaps
232
220
# optional data after the binary block, in which case you will need to
233
221
# override this test
234
- if not self .header_class :
235
- pytest .skip ()
236
222
hdr = self .header_class ()
237
223
str_io = BytesIO ()
238
224
hdr .write_to (str_io )
239
225
assert str_io .getvalue () == hdr .binaryblock
240
226
241
227
def test_structarr (self ):
242
228
# structarr attribute also read only
243
- if not self .header_class :
244
- pytest .skip ()
245
229
hdr = self .header_class ()
246
230
# Just check we can get structarr
247
231
hdr .structarr
@@ -260,8 +244,6 @@ def assert_no_log_err(self, hdr):
260
244
261
245
def test_bytes (self ):
262
246
# Test get of bytes
263
- if not self .header_class :
264
- pytest .skip ()
265
247
hdr1 = self .header_class ()
266
248
bb = hdr1 .binaryblock
267
249
hdr2 = self .header_class (hdr1 .binaryblock )
@@ -292,8 +274,6 @@ def test_bytes(self):
292
274
293
275
def test_as_byteswapped (self ):
294
276
# Check byte swapping
295
- if not self .header_class :
296
- pytest .skip ()
297
277
hdr = self .header_class ()
298
278
assert hdr .endianness == native_code
299
279
# same code just returns a copy
@@ -318,8 +298,6 @@ def check_fix(self, *args, **kwargs):
318
298
319
299
def test_empty_check (self ):
320
300
# Empty header should be error free
321
- if not self .header_class :
322
- pytest .skip ()
323
301
hdr = self .header_class ()
324
302
hdr .check_fix (error_level = 0 )
325
303
@@ -329,8 +307,6 @@ def _dxer(self, hdr):
329
307
return self .header_class .diagnose_binaryblock (binblock )
330
308
331
309
def test_str (self ):
332
- if not self .header_class :
333
- pytest .skip ()
334
310
hdr = self .header_class ()
335
311
# Check something returns from str
336
312
s1 = str (hdr )
@@ -344,8 +320,6 @@ class _TestLabeledWrapStruct(_TestWrapStructBase):
344
320
def test_get_value_label (self ):
345
321
# Test get value label method
346
322
# Make a new class to avoid overwriting recoders of original
347
- if not self .header_class :
348
- pytest .skip ()
349
323
class MyHdr (self .header_class ):
350
324
_field_recoders = {}
351
325
hdr = MyHdr ()
0 commit comments