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

Method test_issue_4920

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

Source from the content-addressed store, hash-verified

1515 self.assertEqual(set(s), set('cd'))
1516
1517 def test_issue_4920(self):
1518 # MutableSet.pop() method did not work
1519 class MySet(MutableSet):
1520 __slots__=['__s']
1521 def __init__(self,items=None):
1522 if items is None:
1523 items=[]
1524 self.__s=set(items)
1525 def __contains__(self,v):
1526 return v in self.__s
1527 def __iter__(self):
1528 return iter(self.__s)
1529 def __len__(self):
1530 return len(self.__s)
1531 def add(self,v):
1532 result=v not in self.__s
1533 self.__s.add(v)
1534 return result
1535 def discard(self,v):
1536 result=v in self.__s
1537 self.__s.discard(v)
1538 return result
1539 def __repr__(self):
1540 return "MySet(%s)" % repr(list(self))
1541 items = [5,43,2,1]
1542 s = MySet(items)
1543 r = s.pop()
1544 self.assertEqual(len(s), len(items) - 1)
1545 self.assertNotIn(r, s)
1546 self.assertIn(r, items)
1547
1548 def test_issue8750(self):
1549 empty = WithSet()

Callers

nothing calls this directly

Calls 5

assertNotInMethod · 0.80
assertInMethod · 0.80
MySetClass · 0.70
popMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected