Sha256: 3cbebc63c4f3ce882885c76c56fd693313bce12489c81976a85d087ca6e11e04

Contents?: true

Size: 906 Bytes

Versions: 130

Compression:

Stored size: 906 Bytes

Contents

import unittest

from prime_factors import prime_factors


# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.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

130 entries across 130 versions & 1 rubygems

Version Path
trackler-2.2.1.25 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.24 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.23 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.22 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.21 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.20 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.19 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.18 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.17 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.16 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.15 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.14 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.13 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.12 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.11 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.10 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.9 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.8 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.7 tracks/python/exercises/prime-factors/prime_factors_test.py
trackler-2.2.1.6 tracks/python/exercises/prime-factors/prime_factors_test.py