コード例 #1
0
    def test_sieve_of_eratosthenes(self):
        """
        Test function that calls the real function and checks the return value
        """

        expect_return_value = [2, 3, 5, 7, 11]
        actual_return_value = list(sieve.sieve_of_eratosthenes(12))

        self.assertEqual(expect_return_value, actual_return_value)
コード例 #2
0
def test_manual():

    primes = list(sieve.sieve_of_eratosthenes(30))
    print(primes)
    print('Should be [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]')
コード例 #3
0
def test_assert_fail():

    primes = list(sieve.sieve_of_eratosthenes(30))
    assert (primes == [2, 3, 5, 7, 11, 13, 17, 19, 23])