def test_primes(self): primes = solution.primes() first_five = list(islice(primes, 5)) self.assertEqual(first_five, [2, 3, 5, 7, 11]) self.assertTrue(hasattr(primes, "__iter__")) self.assertTrue(hasattr(primes, "__next__")) self.assertFalse(hasattr(primes, "__getitem__")) self.assertFalse(hasattr(primes, "__len__"))
def test_primes_ten(self): primes = solution.primes() first_ten = list(islice(primes, 10)) result = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] self.assertEqual(first_ten, result)