Пример #1
0
def test_item_iterator_empty():
    frozen = tuple(iterators.item_iterator({}))
    assert len(frozen) == 1, "Must return at least the item itself!"
    assert ((), {}) in frozen

    frozen = tuple(iterators.item_iterator([]))
    assert len(frozen) == 1, "Must return at least the item itself!"
    assert ((), []) in frozen
Пример #2
0
def test_item_iterator():
    tester = {
        'foo': 42,
        'bar': {
            'some': 'dict',
        },
        'baz': [
            {
                1: 2
            },
            {
                3: 4
            },
        ]
    }

    frozen = tuple(iterators.item_iterator(tester))
    assert len(
        frozen) == 9, "Iterator did not yield the correct number of items!"

    # Test for a few paths
    assert ((), tester) in frozen
    assert (('bar', 'some'), 'dict') in frozen
    assert (('baz', 0, 1), 2) in frozen
    assert (('baz', 1), {3: 4}) in frozen
Пример #3
0
def test_item_iterator():
    tester = {
        "foo": 42,
        "bar": {
            "some": "dict",
        },
        "baz": [
            {
                1: 2
            },
            {
                3: 4
            },
        ],
    }

    frozen = tuple(iterators.item_iterator(tester))
    assert len(
        frozen) == 9, "Iterator did not yield the correct number of items!"

    # Test for a few paths
    assert ((), tester) in frozen
    assert (("bar", "some"), "dict") in frozen
    assert (("baz", 0, 1), 2) in frozen
    assert (("baz", 1), {3: 4}) in frozen