From 9037fd538fd56f303da214fd5048e83e39cf910e Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:10:34 -0800 Subject: [PATCH] # Factorial --- kyu_7/factorial/__init__.py | 1 + kyu_7/factorial/factorial.py | 5 ++++- kyu_7/factorial/test_factorial.py | 36 +++++++++++++------------------ 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/kyu_7/factorial/__init__.py b/kyu_7/factorial/__init__.py index e69de29bb2d..0d4024da9d8 100644 --- a/kyu_7/factorial/__init__.py +++ b/kyu_7/factorial/__init__.py @@ -0,0 +1 @@ +"""Factorial.""" \ No newline at end of file diff --git a/kyu_7/factorial/factorial.py b/kyu_7/factorial/factorial.py index 6fc1fdb8bfb..10daa754d9e 100644 --- a/kyu_7/factorial/factorial.py +++ b/kyu_7/factorial/factorial.py @@ -1,5 +1,6 @@ """ -Solution for -> Sum of Numbers +Solution for -> Factorial. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ def factorial(n: int) -> int: """ + Factorial function. + A function to calculate factorial for a given input. If input is below 0 or above 12 throw an exception of type ValueError (Python). diff --git a/kyu_7/factorial/test_factorial.py b/kyu_7/factorial/test_factorial.py index 340ff807274..2bcf153ae7e 100644 --- a/kyu_7/factorial/test_factorial.py +++ b/kyu_7/factorial/test_factorial.py @@ -1,5 +1,6 @@ """ -Test for -> Sum of Numbers +Test for -> Factorial. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_7.factorial.factorial import factorial @@ -25,13 +27,16 @@ url='https://www.codewars.com/kata/54ff0d1f355cfd20e60001fc', name='Source/Kata') class FactorialTestCase(unittest.TestCase): - """ - Testing 'factorial' function - """ + """Testing 'factorial' function.""" - def test_factorial(self): + @parameterized.expand([ + (0, 1, "factorial for 0 is 1"), + (1, 1, "factorial for 1 is 1"), + (2, 2, "factorial for 2 is 2"), + (3, 6, "factorial for 3 is 6")]) + def test_factorial(self, n, expected, msg): """ - Testing 'factorial' function + Testing 'factorial' function. In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less @@ -53,18 +58,7 @@ def test_factorial(self): '