#NEWLINE# def test_writeto_bzip2_fileobj( self ) : #NEWLINE# #INDENT# 'Test writing to a bz2.BZ2File file like object' #NEWLINE# fileobj = bz2 . BZ2File ( self . temp ( 'test.fits.bz2' ) , 'w' ) #NEWLINE# h = fits . PrimaryHDU ( ) #NEWLINE# try : #NEWLINE# #INDENT# h . writeto ( fileobj ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# fileobj . close ( ) #NEWLINE# #UNINDENT# with fits . open ( self . temp ( 'test.fits.bz2' ) ) as hdul : #NEWLINE# #INDENT# assert ( hdul [ 0 ] . header == hdul . header )