2323import numpy as np
2424
2525from ..tmpdirs import InTemporaryDirectory
26-
26+ from .. openers import ImageOpener
2727from ..volumeutils import (array_from_file ,
2828 _is_compressed_fobj ,
2929 array_to_file ,
30- allopen , # for backwards compatibility
31- BinOpener ,
30+ allopen , # for backwards compatibility
3231 fname_ext_ul_case ,
3332 calculate_scale ,
3433 can_cast ,
@@ -928,7 +927,7 @@ def test_seek_tell():
928927 st = functools .partial (seek_tell , write0 = write0 )
929928 bio .seek (0 )
930929 # First write the file
931- with BinOpener (in_file , 'wb' ) as fobj :
930+ with ImageOpener (in_file , 'wb' ) as fobj :
932931 assert_equal (fobj .tell (), 0 )
933932 # already at position - OK
934933 st (fobj , 0 )
@@ -949,7 +948,7 @@ def test_seek_tell():
949948 fobj .write (b'\x02 ' * tail )
950949 bio .seek (0 )
951950 # Now read back the file testing seek_tell in reading mode
952- with BinOpener (in_file , 'rb' ) as fobj :
951+ with ImageOpener (in_file , 'rb' ) as fobj :
953952 assert_equal (fobj .tell (), 0 )
954953 st (fobj , 0 )
955954 assert_equal (fobj .tell (), 0 )
@@ -961,22 +960,22 @@ def test_seek_tell():
961960 st (fobj , 0 )
962961 bio .seek (0 )
963962 # Check we have the expected written output
964- with BinOpener (in_file , 'rb' ) as fobj :
963+ with ImageOpener (in_file , 'rb' ) as fobj :
965964 assert_equal (fobj .read (),
966965 b'\x01 ' * start + b'\x00 ' * diff + b'\x02 ' * tail )
967966 for in_file in ('test2.gz' , 'test2.bz2' ):
968967 # Check failure of write seek backwards
969- with BinOpener (in_file , 'wb' ) as fobj :
968+ with ImageOpener (in_file , 'wb' ) as fobj :
970969 fobj .write (b'g' * 10 )
971970 assert_equal (fobj .tell (), 10 )
972971 seek_tell (fobj , 10 )
973972 assert_equal (fobj .tell (), 10 )
974973 assert_raises (IOError , seek_tell , fobj , 5 )
975974 # Make sure read seeks don't affect file
976- with BinOpener (in_file , 'rb' ) as fobj :
975+ with ImageOpener (in_file , 'rb' ) as fobj :
977976 seek_tell (fobj , 10 )
978977 seek_tell (fobj , 0 )
979- with BinOpener (in_file , 'rb' ) as fobj :
978+ with ImageOpener (in_file , 'rb' ) as fobj :
980979 assert_equal (fobj .read (), b'g' * 10 )
981980
982981
@@ -1004,15 +1003,6 @@ def seek(self, *args):
10041003 assert_equal (bio .getvalue (), ZEROB * 20 )
10051004
10061005
1007- def test_BinOpener ():
1008- # Test that BinOpener does add '.mgz' as gzipped file type
1009- with InTemporaryDirectory ():
1010- with BinOpener ('test.gz' , 'w' ) as fobj :
1011- assert_true (hasattr (fobj .fobj , 'compress' ))
1012- with BinOpener ('test.mgz' , 'w' ) as fobj :
1013- assert_true (hasattr (fobj .fobj , 'compress' ))
1014-
1015-
10161006def test_fname_ext_ul_case ():
10171007 # Get filename ignoring the case of the filename extension
10181008 with InTemporaryDirectory ():
0 commit comments