@@ -25,6 +25,9 @@ def setup(self):
2525 t ["booleans" ] = t ["floats" ] > 0.5
2626 t .write (temp , format = "fits" )
2727
28+ # pytest compat
29+ setup_method = setup
30+
2831 def time_read_nommap (self ):
2932 try :
3033 Table .read (self .table_file , format = "fits" , memmap = False )
@@ -42,7 +45,7 @@ def time_write(self):
4245 t .write (table_bytes , format = "fits" )
4346
4447
45- class FITSBinTableHDU :
48+ class FITSBinTableHDUBenchmarks :
4649 def time_from_columns_bytes (self ):
4750 x = np .repeat (b"a" , 2_000_000 )
4851 array = np .array (x , dtype = [("col" , "S1" )])
@@ -57,7 +60,7 @@ def make_header(ncards=1000):
5760 return fits .Header (cards )
5861
5962
60- class FITSHeader :
63+ class FITSHeaderBenchmarks :
6164 """
6265 Tests of the Header interface
6366 """
@@ -66,6 +69,9 @@ def setup(self):
6669 self .hdr = make_header ()
6770 self .hdr_string = self .hdr .tostring ()
6871
72+ # pytest compat
73+ setup_method = setup
74+
6975 def time_get_int (self ):
7076 self .hdr .get ("INT999" )
7177
@@ -85,21 +91,23 @@ def time_fromstring(self):
8591 fits .Header .fromstring (self .hdr_string )
8692
8793
88- class FITSHDUList :
94+ class FITSHDUListBenchmarks :
8995 """
9096 Tests of the HDUList interface
9197 """
9298
93- filename = "many_hdu.fits"
94-
9599 def setup_cache (self ):
100+ self .filename = NamedTemporaryFile (delete = False ).name
96101 hdr = make_header ()
97102 hdul = fits .HDUList (
98103 [fits .PrimaryHDU (header = hdr )]
99104 + [fits .ImageHDU (header = hdr ) for _ in range (30 )]
100105 )
101106 hdul .writeto (self .filename )
102107
108+ # pytest compat
109+ setup_method = setup_cache
110+
103111 def time_getheader (self ):
104112 fits .getheader (self .filename )
105113
0 commit comments