MCPcopy Create free account
hub / github.com/grantjenks/python-sortedcontainers / test_itemsview

Function test_itemsview

tests/test_coverage_sorteddict.py:430–468  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

428 values.index(100)
429
430def test_itemsview():
431 mapping = [(val, pos) for pos, val in enumerate(string.ascii_lowercase)]
432 temp = SortedDict(mapping[:13])
433 items = temp.items()
434
435 assert len(items) == 13
436 assert ('a', 0) in items
437 assert list(items) == mapping[:13]
438 assert items[0] == ('a', 0)
439 assert items[-3:] == [('k', 10), ('l', 11), ('m', 12)]
440 assert list(reversed(items)) == list(reversed(mapping[:13]))
441 assert items.index(('f', 5)) == 5
442 assert items.count(('m', 12)) == 1
443 assert items.isdisjoint([('0', 26), ('1', 27)])
444 assert not items.isdisjoint([('a', 0), ('b', 1)])
445
446 temp.update(mapping[13:])
447
448 assert len(items) == 26
449 assert ('z', 25) in items
450 assert list(items) == mapping
451
452 that = dict(mapping)
453 that_items = get_itemsview(that)
454
455 assert items == that_items
456 assert not (items != that_items)
457 assert not (items < that_items)
458 assert not (items > that_items)
459 assert items <= that_items
460 assert items >= that_items
461
462 assert list(items & that_items) == mapping
463 assert list(items | that_items) == mapping
464 assert list(items - that_items) == []
465 assert list(items ^ that_items) == []
466
467 items = SortedDict(mapping[:2]).items()
468 assert repr(items) == "SortedItemsView(SortedDict({'a': 0, 'b': 1}))"
469
470def test_items_view_index():
471 mapping = [(val, pos) for pos, val in enumerate(string.ascii_lowercase)]

Callers

nothing calls this directly

Calls 6

itemsMethod · 0.95
updateMethod · 0.95
SortedDictClass · 0.90
get_itemsviewFunction · 0.85
indexMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected