forked from reingart/exercism
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprime_factors_test.py
More file actions
47 lines (32 loc) · 1.37 KB
/
prime_factors_test.py
File metadata and controls
47 lines (32 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/prime-factors/canonical-data.json
# File last updated on 2023-07-19
import unittest
from prime_factors import (
factors,
)
class PrimeFactorsTest(unittest.TestCase):
def test_no_factors(self):
self.assertEqual(factors(1), [])
def test_prime_number(self):
self.assertEqual(factors(2), [2])
def test_another_prime_number(self):
self.assertEqual(factors(3), [3])
def test_square_of_a_prime(self):
self.assertEqual(factors(9), [3, 3])
def test_product_of_first_prime(self):
self.assertEqual(factors(4), [2, 2])
def test_cube_of_a_prime(self):
self.assertEqual(factors(8), [2, 2, 2])
def test_product_of_second_prime(self):
self.assertEqual(factors(27), [3, 3, 3])
def test_product_of_third_prime(self):
self.assertEqual(factors(625), [5, 5, 5, 5])
def test_product_of_first_and_second_prime(self):
self.assertEqual(factors(6), [2, 3])
def test_product_of_primes_and_non_primes(self):
self.assertEqual(factors(12), [2, 2, 3])
def test_product_of_primes(self):
self.assertEqual(factors(901255), [5, 17, 23, 461])
def test_factors_include_a_large_prime(self):
self.assertEqual(factors(93819012551), [11, 9539, 894119])