Beispiel #1
0
def test_del_keyword():
    """We can delete a keyword"""

    from sherpa.astro.io.meta import Meta
    store = Meta()
    store['x1'] = 1
    store['u1'] = 2
    del store['x1']

    assert store.keys() == ['u1']
    assert store.values() == [2]
Beispiel #2
0
def test_add_keyword(value):
    """Can add a keyword"""

    from sherpa.astro.io.meta import Meta
    store = Meta()
    store['key'] = value
    assert store.keys() == ['key']
    assert store.has_key('key')
    assert len(store.values()) == 1

    svalue = store['key']
    assert svalue == value
Beispiel #3
0
def test_del_missing_keyword():
    """We can not delete a keyword that doesn't exist"""

    from sherpa.astro.io.meta import Meta
    store = Meta()
    store['x1'] = 1
    store['u1'] = 2
    with pytest.raises(KeyError):
        del store['y1']

    assert store.keys() == ['u1', 'x1']
    assert store.values() == [2, 1]
Beispiel #4
0
def test_keyword_order():
    """keys are sorted, not based on input order"""

    from sherpa.astro.io.meta import Meta
    store = Meta()
    store['key2'] = 1
    store['key1'] = 2
    store['a'] = True
    store['A'] = False

    keys = store.keys()
    assert keys == ['A', 'a', 'key1', 'key2']

    vals = store.values()
    assert vals == [False, True, 2, 1]