示例#1
0
def test_rrd_unmap_original():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    assert r["foo"] == 2
    assert r.original == {1: 2}
    r.unmap()
    assert r.original == {1: 2}
示例#2
0
def test_rrd_unmap():
    r = RRD({1: 2})
    assert r[1] == 2
    r.remap({1: "foo"})
    assert r["foo"] == 2
    with pytest.raises(KeyError):
        r[1]
    r.unmap()
    assert r[1] == 2
    with pytest.raises(KeyError):
        r["foo"]
示例#3
0
def test_rrd_unmap_reversed():
    r = RRD({1: 2})
    assert not hasattr(r, "_reversed")
    r.reversed
    assert hasattr(r, "_reversed")
    r.remap({1: "foo"})
    assert not hasattr(r, "_reversed")
    r.reversed
    assert hasattr(r, "_reversed")
    r.unmap()
    assert not hasattr(r, "_reversed")
    assert r.reversed == {2: 1}
    assert hasattr(r, "_reversed")