Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_collections.py
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
def test_immutabledict_copy_pop(): | def test_immutabledict_copy_pop(): | ||||
d = ImmutableDict({"foo": "bar", "baz": "qux"}) | d = ImmutableDict({"foo": "bar", "baz": "qux"}) | ||||
assert d.copy_pop("foo") == ("bar", ImmutableDict({"baz": "qux"})) | assert d.copy_pop("foo") == ("bar", ImmutableDict({"baz": "qux"})) | ||||
assert d.copy_pop("not a key") == (None, d) | assert d.copy_pop("not a key") == (None, d) | ||||
def test_hash(): | |||||
assert hash(ImmutableDict()) == hash(ImmutableDict({})) | |||||
assert hash(ImmutableDict({"foo": "bar"})) == hash(ImmutableDict({"foo": "bar"})) | |||||
assert hash(ImmutableDict({"foo": "bar", "baz": "qux"})) == hash( | |||||
ImmutableDict({"foo": "bar", "baz": "qux"}) | |||||
) | |||||
assert hash(ImmutableDict({"foo": "bar", "baz": "qux"})) == hash( | |||||
ImmutableDict({"baz": "qux", "foo": "bar"}) | |||||
) | |||||
def test_equality_order(): | |||||
assert ImmutableDict({"foo": "bar", "baz": "qux"}) == ImmutableDict( | |||||
{"foo": "bar", "baz": "qux"} | |||||
) | |||||
assert ImmutableDict({"foo": "bar", "baz": "qux"}) == ImmutableDict( | |||||
{"baz": "qux", "foo": "bar"} | |||||
) |