How to use the bidict._util._iteritems_args_kw function in bidict

To help you get started, we’ve selected a few bidict examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jab / bidict / tests / test_hypothesis.py View on Github external
def test_iter_items_arg_kw(arg0_pairs, kw_pairs):
    """Test that :func:`bidict.items` works correctly."""
    with pytest.raises(TypeError):
        _iteritems_args_kw('too', 'many', 'args')
    assert list(_iteritems_args_kw(arg0_pairs)) == list(arg0_pairs)
    assert list(_iteritems_args_kw(OrderedDict(kw_pairs))) == list(kw_pairs)
    kwdict = dict(kw_pairs)
    # Create an iterator over both arg0_pairs and kw_pairs.
    arg0_kw_items = _iteritems_args_kw(arg0_pairs, **kwdict)
    # Consume the initial (arg0) pairs of the iterator, checking they match arg0.
    assert all(check == expect for (check, expect) in izip(arg0_kw_items, arg0_pairs))
    # Consume the remaining (kw) pairs of the iterator, checking they match kw.
    assert all(kwdict[k] == v for (k, v) in arg0_kw_items)
    with pytest.raises(StopIteration):
        next(arg0_kw_items)
github jab / bidict / tests / properties / test_properties.py View on Github external
def test_iteritems_args_kw(arg0, kw):
    """:func:`bidict._iteritems_args_kw` should work correctly."""
    arg0_1, arg0_2 = tee(arg0)
    it = _iteritems_args_kw(arg0_1, **kw)
    # Consume the first `len(arg0)` pairs, checking that they match `arg0`.
    assert all(check == expect for (check, expect) in zip(it, arg0_2))
    with pytest.raises(StopIteration):
        next(arg0_1)  # Iterating `it` should have consumed all of `arg0_1`.
    # Consume the remaining pairs, checking that they match `kw`.
    # Once min PY version required is higher, can check that the order matches `kw` too.
    assert all(kw[k] == v for (k, v) in it)
    with pytest.raises(StopIteration):
        next(it)
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_iter_items_arg_kw(arg0_pairs, kw_pairs):
    """Test that :func:`bidict.items` works correctly."""
    with pytest.raises(TypeError):
        _iteritems_args_kw('too', 'many', 'args')
    assert list(_iteritems_args_kw(arg0_pairs)) == list(arg0_pairs)
    assert list(_iteritems_args_kw(OrderedDict(kw_pairs))) == list(kw_pairs)
    kwdict = dict(kw_pairs)
    # Create an iterator over both arg0_pairs and kw_pairs.
    arg0_kw_items = _iteritems_args_kw(arg0_pairs, **kwdict)
    # Consume the initial (arg0) pairs of the iterator, checking they match arg0.
    assert all(check == expect for (check, expect) in izip(arg0_kw_items, arg0_pairs))
    # Consume the remaining (kw) pairs of the iterator, checking they match kw.
    assert all(kwdict[k] == v for (k, v) in arg0_kw_items)
    with pytest.raises(StopIteration):
        next(arg0_kw_items)
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_iter_items_arg_kw(arg0_pairs, kw_pairs):
    """Test that :func:`bidict.items` works correctly."""
    with pytest.raises(TypeError):
        _iteritems_args_kw('too', 'many', 'args')
    assert list(_iteritems_args_kw(arg0_pairs)) == list(arg0_pairs)
    assert list(_iteritems_args_kw(OrderedDict(kw_pairs))) == list(kw_pairs)
    kwdict = dict(kw_pairs)
    # Create an iterator over both arg0_pairs and kw_pairs.
    arg0_kw_items = _iteritems_args_kw(arg0_pairs, **kwdict)
    # Consume the initial (arg0) pairs of the iterator, checking they match arg0.
    assert all(check == expect for (check, expect) in izip(arg0_kw_items, arg0_pairs))
    # Consume the remaining (kw) pairs of the iterator, checking they match kw.
    assert all(kwdict[k] == v for (k, v) in arg0_kw_items)
    with pytest.raises(StopIteration):
        next(arg0_kw_items)
github jab / bidict / tests / properties / test_properties.py View on Github external
def test_iteritems_args_kw_raises_on_too_many_args():
    """:func:`bidict._iteritems_args_kw` should raise if given too many arguments."""
    with pytest.raises(TypeError):
        _iteritems_args_kw('too', 'many', 'args')
github jab / bidict / tests / test_hypothesis.py View on Github external
def test_iter_items_arg_kw(arg0_pairs, kw_pairs):
    """Test that :func:`bidict.items` works correctly."""
    with pytest.raises(TypeError):
        _iteritems_args_kw('too', 'many', 'args')
    assert list(_iteritems_args_kw(arg0_pairs)) == list(arg0_pairs)
    assert list(_iteritems_args_kw(OrderedDict(kw_pairs))) == list(kw_pairs)
    kwdict = dict(kw_pairs)
    # Create an iterator over both arg0_pairs and kw_pairs.
    arg0_kw_items = _iteritems_args_kw(arg0_pairs, **kwdict)
    # Consume the initial (arg0) pairs of the iterator, checking they match arg0.
    assert all(check == expect for (check, expect) in izip(arg0_kw_items, arg0_pairs))
    # Consume the remaining (kw) pairs of the iterator, checking they match kw.
    assert all(kwdict[k] == v for (k, v) in arg0_kw_items)
    with pytest.raises(StopIteration):
        next(arg0_kw_items)