Exemple #1
0
    def test_read_file_like_object(self):
        """Test reading a FITS file from a file-like object."""

        filelike = BytesIO()
        with open(self.data('test0.fits'), 'rb') as f:
            filelike.write(f.read())
        filelike.seek(0)
        with ignore_warnings():
            assert len(fits.open(filelike)) == 5
Exemple #2
0
    def test_read_file_like_object(self):
        """Test reading a FITS file from a file-like object."""

        filelike = BytesIO()
        with open(self.data("test0.fits"), "rb") as f:
            filelike.write(f.read())
        filelike.seek(0)
        with ignore_warnings():
            assert_equal(len(pyfits.open(filelike)), 5)
Exemple #3
0
 def hdulist(self):
     self._file.seek(self._datLoc)
     fileobj = BytesIO()
     # Read the data into a BytesIO--reading directly from the file
     # won't work (at least for gzipped files) due to problems deep
     # within the gzip module that make it difficult to read gzip files
     # embedded in another file
     fileobj.write(self._file.read(self.size))
     fileobj.seek(0)
     if self._header['COMPRESS']:
         fileobj = gzip.GzipFile(fileobj=fileobj)
     return HDUList.fromfile(fileobj, mode='readonly')