Skip to content

Commit

Permalink
==kyu_7.factorial
Browse files Browse the repository at this point in the history
kyu_7/easy_line/__init__.py:1:0: R0801: Similar lines in 2 files
==kyu_7.factorial.test_factorial:[42:49]
==kyu_7.vaporcode.test_vaporcode:[33:40]
        allure.dynamic.severity(allure.severity_level.NORMAL)
        allure.dynamic.description_html('<h3>Codewars badge:</h3>'
                                        '<img src="https://www.codewars.com/users/myFirstCode'
                                        '/badges/large">'
                                        '<h3>Test Description:</h3>'
                                        "<p></p>")
 (duplicate-code)
  • Loading branch information
ikostan committed Sep 27, 2024
1 parent ac46337 commit e9cdcf9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
12 changes: 7 additions & 5 deletions kyu_7/factorial/factorial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Created by Egor Kostan.
# GitHub: https://github.com/ikostan
# LinkedIn: https://www.linkedin.com/in/egor-kostan/
"""
Solution for -> Sum of Numbers
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def factorial(n: int) -> int:
Expand All @@ -11,12 +13,12 @@ def factorial(n: int) -> int:
:param n:
:return:
"""

if n < 0 or n > 12:
raise ValueError('Invalid input: {}'.format(n))

result = 1
result: int = 1
while n > 0:
result *= n
n -= 1

return result
29 changes: 16 additions & 13 deletions kyu_7/factorial/test_factorial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Created by Egor Kostan.
# GitHub: https://github.com/ikostan
# LinkedIn: https://www.linkedin.com/in/egor-kostan/
"""
Test for -> Sum of Numbers
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""

# FUNDAMENTALS ALGORITHMS NUMBERS

Expand Down Expand Up @@ -38,24 +40,25 @@ def test_factorial(self):
ValueError (Python).
:return:
"""

# pylint: disable-msg=R0801
allure.dynamic.title("Testing 'factorial' function")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html('<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<h3>Test Description:</h3>'
"<p></p>")

allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable-msg=R0801
with allure.step("Enter a number and verify the output"):
data = [
data: tuple = (
(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"),
]
(3, 6, "factorial for 3 is 6"))

for n, expected, msg in data:

Check notice on line 61 in kyu_7/factorial/test_factorial.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_7/factorial/test_factorial.py#L61

Trailing whitespace (trailing-whitespace)
print_log(n=n,
expected=expected,
msg=msg)
Expand Down

0 comments on commit e9cdcf9

Please sign in to comment.