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, )
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
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
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]
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
def test_auto_map___reversed__(keys: Keys) -> None: assert [*reversed(automap.AutoMap(keys))] == [*reversed([*keys])]
def test_auto_map___iter__(keys: Keys) -> None: assert [*automap.AutoMap(keys)] == [*keys]
def test_auto_map___len__(keys: Keys) -> None: assert len(automap.AutoMap(keys)) == len(keys)