def test_set_xsstate_xset(): """Check set_xsstate works for an xset command. """ from sherpa.astro import xspec ostate = xspec.get_xsstate() key = 'a-test-keyword' val = '/foo/bar/baz.pha' while key in ostate['modelstrings']: key += "a" ukey = key.upper() # There should be no value for this key (since it isn't # in modelstrings by construction). # assert key not in xspec.modelstrings assert xspec.get_xsxset(key) == '' nstate = copy.deepcopy(ostate) nstate['modelstrings'][key] = val xspec.set_xsstate(nstate) assert xspec.get_xsxset(key) == val assert ukey in xspec.modelstrings assert xspec.modelstrings[ukey] == val xspec.set_xsstate(ostate) # Unfortunately, due to there being no attempt at clearing out the # XSET settings (e.g. removing existing settings before restoring # the state), the following tests fail. # # TODO: the code should probably be updated to fix this # # assert xspec.get_xsxset(key) == '' # assert xspec.get_xsstate() == ostate xspec.set_xsxset(key, '') del xspec.modelstrings[ukey] assert xspec.get_xsstate() == ostate
def test_xsxset_get(clean_astro_ui): import sherpa.astro.xspec as xs # TEST CASE #1 Case insentitive keys xs.set_xsxset('fooBar', 'somevalue') assert xs.get_xsxset('Foobar') == 'somevalue'
def test_xsxset_get(self): # TEST CASE #1 Case insentitive keys xs.set_xsxset('fooBar', 'somevalue') self.assertEqual('somevalue', xs.get_xsxset('Foobar'))
def test_xsxset_get(self): import sherpa.astro.xspec as xs # TEST CASE #1 Case insentitive keys xs.set_xsxset('fooBar', 'somevalue') self.assertEqual('somevalue', xs.get_xsxset('Foobar'))
def setfunc(val): xspec.set_xsxset(DEFAULT_XSET_NAME.lower(), val)