def test4(): '''ASTRODATA-close TEST 4: SEF, Closing AD subdata will not affect hdulist ''' ad = AstroData(sci1) ad['SCI', 1].close() assert_not_equal(ad.hdulist, None, msg='original hdulist is None') ad.close()
def test2(): '''ASTRODATA-mode TEST 2: Overwrite readonly AD using name change''' ad = AstroData(sci123) outfile = 'testmode2.fits' if os.path.exists(outfile): os.remove(outfile) ad.filename = outfile ad.write() assert_true(os.path.isfile(outfile), 'ad.write() FAIL') os.remove(outfile) ad.close()
def test4(): """ ASTRODATA-deepcopy TEST 4: Orig attribute change does not affect copy (SEF) """ ad = AstroData(sci1) adDeepcopy = deepcopy(ad) savedFilename = ad._AstroData__origFilename ad.mode = "update" ad._AstroData__origFilename = "newfilename.fits" eq_(adDeepcopy.mode, "readonly", msg="Deepcopy Failure, mode is not readonly") ad.close() adDeepcopy.close()
def test2(): """ ASTRODATA-deepcopy TEST 2: Orig attribute change does not affect copy (MEF) """ ad = AstroData(sci123) adDeepcopy = deepcopy(ad) savedFilename = ad._AstroData__origFilename ad._AstroData__origFilename = "newfilename.fits" eq_(adDeepcopy._AstroData__origFilename, savedFilename, msg="The attribute _AstroData__origFilename has been altered in deepcopy") ad.close() adDeepcopy.close()
def test1(): '''ASTRODATA-iter TEST 1: Compare for AD and for HDUList (MEF)''' ad = AstroData(sci123) aditerImageObjectIdList = [] hduImageObjectIdList = [] for a in ad: aditerImageObjectIdList.append(id(a.hdulist[1])) for phu in ad.hdulist[1:]: hduImageObjectIdList.append(id(phu)) ok_(aditerImageObjectIdList == hduImageObjectIdList, \ msg='Object ids are not the same') ad.close()
def test1(): """ASTRODATA-deepcopy TEST 1: Pyfits HDUList id's are not equal (MEF)""" ad = AstroData(sci123) adDeepcopy = deepcopy(ad) adIdlist = [] adDeepcopyIdlist = [] for ext in ad: adIdlist.append(id(ext.hdulist[1])) for dext in adDeepcopy: adDeepcopyIdlist.append(id(dext.hdulist[1])) assert_not_equal(adIdlist, adDeepcopyIdlist, msg="hdulist ids are equal") ad.close() adDeepcopy.close()
def test5(): '''ASTRODATA-mode TEST 5: Clobber changed readonly file''' outfile = 'testmode5.fits' if os.path.exists(outfile): os.remove(outfile) shutil.copy(sci123, outfile) ad = AstroData(outfile, mode='update') ad.hdulist[0].header['INSTRUME'] = 'GMOS-S' ad.write(clobber=True) ad.close() ad = AstroData(outfile) ok_(ad.hdulist[0].header['INSTRUME'] == 'GMOS-S', msg='Keyword is different') os.remove(outfile) ad.close()
def test3(): """ASTRODATA-inferred TEST 3: 'SCI' 1 if no XNAM found (SEF)""" testhdulist = pyfits.open(sci1) hlist = [] alist = [] for hdu in testhdulist[1:]: hlist.append(hdu.name) print("\n\n HDUList EXTNAME: %s" % hlist) ad = AstroData(testhdulist) alist.append((ad[0].extname(), ad[0].extver())) eq_(ad[0].extname(), "SCI", msg="extname is not sci") eq_(ad[0].extver(), 1, msg="extver is incorrect") print("\n AD (EXTNAME,EXTVER): %s" % alist) ad.close() testhdulist.close()
def test1(): """ASTRODATA-inferred TEST 1: 'SCI',<VER> for all exts if no XNAMs found (MEF)""" testhdulist = pyfits.open(sci123) # make it so no XNAM found for hdu in testhdulist[1:]: hdu.name = "" hdu.header.rename_key("extname","xname" ) hlist = [] alist = [] for hdu in testhdulist[1:]: hlist.append(hdu.name) print("\n\n HDUList EXTNAME: %s" % hlist) ad = AstroData(testhdulist) for i in range(0,3): alist.append((ad[i].extname(), ad[i].extver())) eq_(ad[i].extname(), 'SCI', msg="extname is not sci") eq_(ad[i].extver(), i + 1, msg="extver is incorrect") print("\n AD (EXTNAME,EXTVER): %s" % alist) ad.close() testhdulist.close()
def test3(): '''ASTRODATA-mode TEST 3: Clobber unchanged readonly file''' ad = AstroData(sci123) ad.write(clobber=True) assert_true(os.path.isfile(sci123), 'Clobber fail') ad.close()
def test3(): """ASTRODATA-close TEST 3: SEF, Closing AD will cause hdulist to be None """ ad = AstroData(sci1) ad.close() eq_(ad.hdulist, None, msg="ad.hdulist is not None")
def test1(): '''ASTRODATA-close TEST 1: MEF, Closing AD will cause hdulist to be None ''' ad = AstroData(sci123) ad.close() eq_(ad.hdulist, None, msg='ad.hdulist is not None')