Skip to content

Commit 72b9b60

Browse files
committed
Fix tests
1 parent 0863365 commit 72b9b60

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

pysynphot/test/test_mergewavesets.py

+30-9
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
from ..obsbandpass import ObsBandpass
1010
from ..observation import Observation
1111
from ..reddening import Extinction
12+
from ..refs import getref, setref
1213
from ..spectrum import BlackBody, FileSourceSpectrum, MergeWaveSets, MERGETHRESH
1314

15+
orig_graphtable = None
16+
orig_comptable = None
17+
1418

1519
@use_cdbs
1620
def test_merge_wave_sets():
@@ -28,18 +32,35 @@ def test_merge_wave_sets():
2832

2933

3034
@use_cdbs
31-
def test_qso_countrate():
35+
class TestQSOCountrate(object):
3236
"""
3337
Extinction curve waveset should not be merged into composite spectrum
3438
when applied. See https://github.com/spacetelescope/pysynphot/issues/44 .
3539
"""
36-
bp = ObsBandpass('acs,hrc,f850lp')
40+
@classmethod
41+
def setup_class(cls):
42+
global orig_graphtable, orig_comptable
43+
cfg = getref()
44+
orig_graphtable = cfg['graphtable']
45+
orig_comptable = cfg['comptable']
46+
47+
# Answers computed using specified tables
48+
mtab = os.path.join(os.environ['PYSYN_CDBS'], 'mtab')
49+
setref(graphtable=os.path.join(mtab, '14l1632sm_tmg.fits'),
50+
comptable=os.path.join(mtab, 'OLD_FILES', '16n1832tm_tmc.fits'))
51+
52+
def test_countrate(self):
53+
bp = ObsBandpass('acs,hrc,f850lp')
54+
55+
fname = get_pkg_data_filename(os.path.join('data', 'qso_template.fits'))
56+
qso = FileSourceSpectrum(fname)
57+
sp_ext = qso * Extinction(1.0, 'mwavg')
58+
sp = sp_ext.renorm(20, 'vegamag', ObsBandpass('johnson,v'), force=True)
3759

38-
fname = get_pkg_data_filename(os.path.join('data', 'qso_template.fits'))
39-
qso = FileSourceSpectrum(fname)
40-
sp_ext = qso * Extinction(1.0, 'mwavg')
41-
sp = sp_ext.renorm(20, 'vegamag', ObsBandpass('johnson,v'), force=True)
60+
obs = Observation(sp, bp, force='taper')
61+
c = obs.countrate()
62+
np.testing.assert_allclose(c, 2.3554364232173565e-05)
4263

43-
obs = Observation(sp, bp, force='taper')
44-
c = obs.countrate()
45-
np.testing.assert_allclose(c, 2.3554364232173565e-05)
64+
@classmethod
65+
def teardown_class(cls):
66+
setref(graphtable=orig_graphtable, comptable=orig_comptable)

0 commit comments

Comments
 (0)