Sha256: da1ce05495e44b7788165ea39437abd9fee0f2e594cc64c8ba1988126108489f

Contents?: true

Size: 909 Bytes

Versions: 125

Compression:

Stored size: 909 Bytes

Contents

import unittest

from nth_prime import nth_prime


# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0

class NthPrimeTests(unittest.TestCase):
    def test_first_prime(self):
        self.assertEqual(nth_prime(1), 2)

    def test_second_prime(self):
        self.assertEqual(nth_prime(2), 3)

    def test_sixth_prime(self):
        self.assertEqual(nth_prime(6), 13)

    def test_big_prime(self):
        self.assertEqual(nth_prime(10001), 104743)

    def test_there_is_no_zeroth_prime(self):
        with self.assertRaises(ValueError):
            nth_prime(0)

    # additional track specific test
    def test_first_twenty_primes(self):
        self.assertEqual([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
                          37, 41, 43, 47, 53, 59, 61, 67, 71],
                         [nth_prime(n) for n in range(1, 21)])


if __name__ == '__main__':
    unittest.main()

Version data entries

125 entries across 125 versions & 1 rubygems

Version Path
trackler-2.1.0.7 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.1.0.6 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.1.0.5 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.1.0.4 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.1.0.3 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.1.0.2 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.1.0.1 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.1.0.0 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.55 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.54 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.53 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.52 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.51 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.50 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.49 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.48 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.47 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.46 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.45 tracks/python/exercises/nth-prime/nth_prime_test.py
trackler-2.0.8.44 tracks/python/exercises/nth-prime/nth_prime_test.py