MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_issue_4920

Method test_issue_4920

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected