Skip to content

Commit

Permalink
Update test_primes.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 14, 2024
1 parent 93d9495 commit 943dca4
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions kyu_5/master_your_primes_sieve_with_memoization/test_primes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import unittest
import allure
from parameterized import parameterized
from utils.log_func import print_log
from kyu_5.master_your_primes_sieve_with_memoization.primes \
import is_prime
Expand All @@ -32,7 +33,28 @@
class PrimesTestCase(unittest.TestCase):
"""Testing is_prime function."""

def test_is_primes(self):
@parameterized.expand([
(1, False),
(2, True),
(5, True),
(143, False),
(-1, False),
(29, True),
(53, True),
(529, False),
(4539131, True),
(110268984695, False),
(97444114757, False),
(7301162915, False),
(8033908462571, False),
(8813991225347, False),
(857561895605, False),
(13, True),
(17, True),
(19, True),
(23, True),
(29, True)])
def test_is_primes(self, number, expected):
"""
Testing is_prime function with various test data.
Expand All @@ -54,31 +76,7 @@ def test_is_primes(self):
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable-msg=R0801
with allure.step("Enter test number and verify the output"):
test_data: tuple = (
(1, False),
(2, True),
(5, True),
(143, False),
(-1, False),
(29, True),
(53, True),
(529, False),
(4539131, True),
(110268984695, False),
(97444114757, False),
(7301162915, False),
(8033908462571, False),
(8813991225347, False),
(857561895605, False),
(13, True),
(17, True),
(19, True),
(23, True),
(29, True))

for data in test_data:
number = data[0]
expected = data[1]
print_log(number=number, expected=expected)
self.assertEqual(expected, is_prime(number))
with allure.step(f"Enter test number: {number} "
f"and verify the output: {expected}."):
print_log(number=number, expected=expected)
self.assertEqual(expected, is_prime(number))

0 comments on commit 943dca4

Please sign in to comment.