def test_repr(self): l0 = memoryslots() l2 = memoryslots(0, 1, 2) a0 = self.type2test(*l0) a2 = self.type2test(*l2) self.assertEqual(str(a0), repr(l0)) self.assertEqual(str(a2), repr(l2)) self.assertEqual(repr(a0), "memoryslots()") self.assertEqual(repr(a2), "memoryslots(0, 1, 2)")
def test_constructors(self): #super().test_constructors() # calling built-in types without argument must return empty self.assertEqual(memoryslots(), ()) self.assertEqual(memoryslots([]), memoryslots([])) self.assertEqual(memoryslots(0, 1, 2, 3), memoryslots(0, 1, 2, 3)) self.assertEqual(memoryslots(''), memoryslots(''))
def test_memoryslotsresizebug(self): # Check that a specific bug in _PyTuple_Resize() is squashed. def f(): for i in range(1000): yield i self.assertEqual(list(memoryslots(*f())), list(range(1000)))
def test_len(self): #super().test_len() self.assertEqual(len(memoryslots()), 0) self.assertEqual(len(memoryslots(0)), 1) self.assertEqual(len(memoryslots(0, 1, 2)), 3)
def test_truth(self): #super().test_truth() self.assertTrue(not memoryslots()) self.assertTrue(memoryslots([42]))