#NEWLINE# def _test_create_fitshdu( self , compression = False ) : #NEWLINE# #INDENT# hdul_orig = fits . open ( self . data ( 'test0.fits' ) , do_not_scale_image_data = True ) #NEWLINE# fitshdu = fits . FitsHDU . fromhdulist ( hdul_orig , compress = compression ) #NEWLINE# hdul_orig . append ( fitshdu ) #NEWLINE# hdul_orig . writeto ( self . temp ( 'tmp.fits' ) , clobber = True ) #NEWLINE# del hdul_orig [ ( - 1 ) ] #NEWLINE# hdul = fits . open ( self . temp ( 'tmp.fits' ) ) #NEWLINE# assert isinstance ( fitshdu [ ( - 1 ) ] , fits . FitsHDU ) #NEWLINE# wrapped = hdul [ ( - 1 ) ] . hdulist #NEWLINE# assert isinstance ( wrapped , fits . HDUList ) #NEWLINE# assert ( hdul_orig . info ( output = False ) == wrapped . info ( output = False ) ) #NEWLINE# assert ( hdul [ 1 ] . data == wrapped [ 1 ] . data ) . all ( ) #NEWLINE# assert ( hdul [ 2 ] . data == wrapped [ 2 ] . data ) . all ( ) #NEWLINE# assert ( hdul [ 3 ] . data == wrapped [ 3 ] . data ) . all ( ) #NEWLINE# assert ( hdul [ 4 ] . data == wrapped [ 4 ] . data ) . all ( )