MCPcopy Index your code
hub / github.com/python/cpython / test_issue26915

Method test_issue26915

Lib/test/test_collections.py:1592–1617  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1590 self.assertTrue(ncs >= cs)
1591
1592 def test_issue26915(self):
1593 # Container membership test should check identity first
1594 class CustomSequence(Sequence):
1595 def __init__(self, seq):
1596 self._seq = seq
1597 def __getitem__(self, index):
1598 return self._seq[index]
1599 def __len__(self):
1600 return len(self._seq)
1601
1602 nan = float('nan')
1603 obj = support.NEVER_EQ
1604 seq = CustomSequence([nan, obj, nan])
1605 containers = [
1606 seq,
1607 ItemsView({1: nan, 2: obj}),
1608 KeysView({1: nan, 2: obj}),
1609 ValuesView({1: nan, 2: obj})
1610 ]
1611 for container in containers:
1612 for elem in container:
1613 self.assertIn(elem, container)
1614 self.assertEqual(seq.index(nan), 0)
1615 self.assertEqual(seq.index(obj), 1)
1616 self.assertEqual(seq.count(nan), 2)
1617 self.assertEqual(seq.count(obj), 1)
1618
1619 def assertSameSet(self, s1, s2):
1620 # coerce both to a real set then check equality

Callers

nothing calls this directly

Calls 8

ItemsViewClass · 0.90
KeysViewClass · 0.90
ValuesViewClass · 0.90
CustomSequenceClass · 0.85
assertInMethod · 0.80
assertEqualMethod · 0.45
indexMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected