Sha256: 75fcef639e3b841dadf2a99b4168f1b318303db5ce47a82ce60dac0ea77edb18

Contents?: true

Size: 907 Bytes

Versions: 73

Compression:

Stored size: 907 Bytes

Contents

import unittest

from prime_factors import prime_factors


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class PrimeFactorsTest(unittest.TestCase):
    def test_no_factors(self):
        self.assertEqual(prime_factors(1), [])

    def test_prime_number(self):
        self.assertEqual(prime_factors(2), [2])

    def test_square_of_a_prime(self):
        self.assertEqual(prime_factors(9), [3, 3])

    def test_cube_of_a_prime(self):
        self.assertEqual(prime_factors(8), [2, 2, 2])

    def test_product_of_primes_and_non_primes(self):
        self.assertEqual(prime_factors(12), [2, 2, 3])

    def test_product_of_primes(self):
        self.assertEqual(prime_factors(901255), [5, 17, 23, 461])

    def test_factors_include_a_large_prime(self):
        self.assertEqual(prime_factors(93819012551), [11, 9539, 894119])


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

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.179 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.178 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.177 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.176 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.175 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.174 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.173 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.172 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.171 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.170 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.169 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.167 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.166 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.165 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.164 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.163 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.162 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.161 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.160 tracks/python/exercises/prime-factors/prime_factors_test.py