Ejemplo n.º 1
0
def test_weakkeydict_popitem(key1=C(), key2=C(), val1="v1", val2="v2"):
    d = WeakKeyIDDictionary()
    d[key1] = val1
    d[key2] = val2

    assert len(d) == 2
    k1, v1 = d.popitem()
    assert len(d) == 1
    assert k1 in (key1, key2) and v1 is (val1 if k1 is key1 else val2)

    k2, v2 = d.popitem()
    assert len(d) == 0
    assert k2 is (key2 if k1 is key1 else key1) and v2 is (val1 if k2 is key1 else val2)
Ejemplo n.º 2
0
def test_weakkeydict_popitem(key1=C(), key2=C(), value1="v1", value2="v2"):
    d = WeakKeyIDDictionary()
    d[key1] = value1
    d[key2] = value2
    assert len(d) == 2
    k, v = d.popitem()
    assert len(d) == 1
    if k is key1:
        assert v is value1
    else:
        assert v is value2
    k, v = d.popitem()
    assert len(d) == 0
    if k is key1:
        assert v is value1
    else:
        assert v is value2
Ejemplo n.º 3
0
def test_weakkeydict_popitem(key1=C(), key2=C(), value1="v1", value2="v2"):
    d = WeakKeyIDDictionary()
    d[key1] = value1
    d[key2] = value2
    assert len(d) == 2
    k, v = d.popitem()
    assert len(d) == 1
    if k is key1:
        assert v is value1
    else:
        assert v is value2
    k, v = d.popitem()
    assert len(d) == 0
    if k is key1:
        assert v is value1
    else:
        assert v is value2