예제 #1
0
def test_issue_3(keys: Keys) -> None:
    hypothesis.assume(keys)
    key = keys.pop()
    a = automap.AutoMap(keys)
    a |= (key, )
    with pytest.raises(ValueError):
        a |= (key, )
예제 #2
0
def test_auto_map___contains__(keys: Keys, others: Keys) -> None:
    a = automap.AutoMap(keys)
    for key in keys:
        assert key in a
    others -= keys
    for key in others:
        assert key not in a
예제 #3
0
def test_pickle(keys: Keys) -> None:
    try:
        hypothesis.assume(pickle.loads(pickle.dumps(keys)) == keys)
    except (TypeError, pickle.PicklingError):
        hypothesis.assume(False)
    a = automap.AutoMap(keys)
    assert pickle.loads(pickle.dumps(a)) == a
예제 #4
0
def test_auto_map___getitem__(keys: Keys, others: Keys) -> None:
    a = automap.AutoMap(keys)
    for index, key in enumerate(keys):
        assert a[key] == index
    others -= keys
    for key in others:
        with pytest.raises(KeyError):
            a[key]
예제 #5
0
def test_auto_map_add(keys: Keys) -> None:
    a = automap.AutoMap()
    for l, key in enumerate(keys):
        assert a.add(key) is None
        assert len(a) == l + 1
        assert a[key] == l
예제 #6
0
def test_auto_map___reversed__(keys: Keys) -> None:
    assert [*reversed(automap.AutoMap(keys))] == [*reversed([*keys])]
예제 #7
0
def test_auto_map___iter__(keys: Keys) -> None:
    assert [*automap.AutoMap(keys)] == [*keys]
예제 #8
0
def test_auto_map___len__(keys: Keys) -> None:
    assert len(automap.AutoMap(keys)) == len(keys)