Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_inverted(bi_cls, init_items):
"""Test that :func:`bidict.inverted` works correctly."""
inv_items = [(v, k) for (k, v) in init_items]
assert list(inverted(init_items)) == inv_items
assert list(inverted(inverted(init_items))) == init_items
some_bidict = bi_cls(init_items)
inv_bidict = bi_cls(inv_items)
assert some_bidict.inv == inv_bidict
assert set(inverted(some_bidict)) == set(inv_items)
assert bi_cls(inverted(inv_bidict)) == some_bidict
def test_inverted_pairs(pairs):
""":func:`bidict.inverted` should yield the inverses of a list of pairs."""
inv = [(v, k) for (k, v) in pairs]
assert list(inverted(pairs)) == inv
assert list(inverted(inverted(pairs))) == pairs
def test_inverted_orderedbidict(ob_and_od):
""":func:`bidict.inverted` should yield the inverse items of an ordered bidict."""
ob, od = ob_and_od
od_inv = OrderedDict((v, k) for (k, v) in od.items())
assert all(i == j for (i, j) in zip(inverted(ob), od_inv.items()))
assert all(i == j for (i, j) in zip(inverted(inverted(ob)), od.items()))
def test_inverted(bi_cls, init_items):
"""Test that :func:`bidict.inverted` works correctly."""
inv_items = [(v, k) for (k, v) in init_items]
assert list(inverted(init_items)) == inv_items
assert list(inverted(inverted(init_items))) == init_items
some_bidict = bi_cls(init_items)
inv_bidict = bi_cls(inv_items)
assert some_bidict.inv == inv_bidict
assert set(inverted(some_bidict)) == set(inv_items)
assert bi_cls(inverted(inv_bidict)) == some_bidict
def test_inverted_pairs(pairs):
""":func:`bidict.inverted` should yield the inverses of a list of pairs."""
inv = [(v, k) for (k, v) in pairs]
assert list(inverted(pairs)) == inv
assert list(inverted(inverted(pairs))) == pairs
def test_inverted(bi_cls, init_items):
"""Test that :func:`bidict.inverted` works correctly."""
inv_items = [(v, k) for (k, v) in init_items]
assert list(inverted(init_items)) == inv_items
assert list(inverted(inverted(init_items))) == init_items
some_bidict = bi_cls(init_items)
inv_bidict = bi_cls(inv_items)
assert some_bidict.inv == inv_bidict
assert set(inverted(some_bidict)) == set(inv_items)
assert bi_cls(inverted(inv_bidict)) == some_bidict
def test_inverted(bi_cls, init_items):
"""Test that :func:`bidict.inverted` works correctly."""
inv_items = [(v, k) for (k, v) in init_items]
assert list(inverted(init_items)) == inv_items
assert list(inverted(inverted(init_items))) == init_items
some_bidict = bi_cls(init_items)
inv_bidict = bi_cls(inv_items)
assert some_bidict.inv == inv_bidict
assert set(inverted(some_bidict)) == set(inv_items)
assert bi_cls(inverted(inv_bidict)) == some_bidict
def test_inverted_bidict(bi_and_cmp_dict):
""":func:`bidict.inverted` should yield the inverse items of a bidict."""
bi, cmp_dict = bi_and_cmp_dict
cmp_dict_inv = OrderedDict((v, k) for (k, v) in cmp_dict.items())
assert set(inverted(bi)) == cmp_dict_inv.items() == bi.inv.items()
assert set(inverted(inverted(bi))) == cmp_dict.items() == bi.inv.inv.items()