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

Method test_Iterable

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

Source from the content-addressed store, hash-verified

966 self.validate_abstract_methods(AsyncIterator, '__anext__')
967
968 def test_Iterable(self):
969 # Check some non-iterables
970 non_samples = [None, 42, 3.14, 1j]
971 for x in non_samples:
972 self.assertNotIsInstance(x, Iterable)
973 self.assertNotIsSubclass(type(x), Iterable)
974 # Check some iterables
975 samples = [bytes(), str(),
976 tuple(), list(), set(), frozenset(), dict(),
977 dict().keys(), dict().items(), dict().values(),
978 _test_gen(),
979 (x for x in []),
980 ]
981 for x in samples:
982 self.assertIsInstance(x, Iterable)
983 self.assertIsSubclass(type(x), Iterable)
984 # Check direct subclassing
985 class I(Iterable):
986 def __iter__(self):
987 return super().__iter__()
988 self.assertEqual(list(I()), [])
989 self.assertNotIsSubclass(str, I)
990 self.validate_abstract_methods(Iterable, '__iter__')
991 self.validate_isinstance(Iterable, '__iter__')
992 # Check None blocking
993 class It:
994 def __iter__(self): return iter([])
995 class ItBlocked(It):
996 __iter__ = None
997 self.assertIsSubclass(It, Iterable)
998 self.assertIsInstance(It(), Iterable)
999 self.assertNotIsSubclass(ItBlocked, Iterable)
1000 self.assertNotIsInstance(ItBlocked(), Iterable)
1001
1002 def test_Reversible(self):
1003 # Check some non-reversibles

Callers

nothing calls this directly

Calls 15

strFunction · 0.85
listClass · 0.85
setFunction · 0.85
_test_genFunction · 0.85
ItClass · 0.85
ItBlockedClass · 0.85
assertNotIsInstanceMethod · 0.80
assertIsInstanceMethod · 0.80
validate_isinstanceMethod · 0.80
IClass · 0.70
assertNotIsSubclassMethod · 0.45

Tested by

no test coverage detected