示例#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")
示例#4
0
def test_rrd_remapping_sets_original():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    assert r.original == {1: 2}
    assert hasattr(r, "_original")
示例#5
0
def test_rrd_remapping_deletes_reversed():
    r = RRD({1: 2})
    r.reversed
    assert hasattr(r, "_reversed")
    r.remap({1: "foo"})
    assert not hasattr(r, "_reversed")
示例#6
0
def test_rrd_remapping():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    assert r["foo"] == 2
示例#7
0
def test_rrd_remapping_multiple():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    r.remap({"foo": "bar"})
    assert r["bar"] == 2
示例#8
0
def test_rrd_remapping_multiple_original():
    r = RRD({1: 2})
    r.remap({1: "foo"})
    r.remap({"foo": "bar"})
    assert r.original == {"foo": 2}