Skip to content

Commit

Permalink
==kyu_7.sum_of_triangular_numbers
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.sum_of_triangular_numbers.test_sum_triangular_numbers:[35:42]
==kyu_7.sum_of_two_lowest_int.test_sum_two_smallest_numbers:[30:37]
        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 24, 2024
1 parent ad23d61 commit 04d3354
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 57 deletions.
11 changes: 6 additions & 5 deletions kyu_7/sum_of_triangular_numbers/sum_triangular_numbers.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 Triangular Numbers
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


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

if n <= 0:
return 0

sum_nums = [0]
sum_nums:list = [0]
for i in range(1, n + 1):
sum_nums.append(sum_nums[-1] + i)

Expand Down
109 changes: 57 additions & 52 deletions kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.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 Triangular Numbers
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""

# FUNDAMENTALS NUMBERS MATHEMATICS ALGORITHMS ARITHMETIC

Expand All @@ -16,9 +18,14 @@
@allure.sub_suite("Unit Tests")
@allure.feature("Math")
@allure.story('Sum of Triangular Numbers')
@allure.tag()
@allure.link(url='',
name='Source/Kata')
@allure.tag('FUNDAMENTALS',
'NUMBERS',
'MATHEMATICS',
'ALGORITHMS',
'ARITHMETIC')
@allure.link(
url='https://www.codewars.com/kata/580878d5d27b84b64c000b51/train/python',
name='Source/Kata')
class SumTriangularNumbersTestCase(unittest.TestCase):
"""
Testing 'sum_triangular_numbers' function
Expand All @@ -30,27 +37,26 @@ def test_sum_triangular_numbers_negative_numbers(self):
with negative numbers
:return:
"""

# pylint: disable-msg=R0801
allure.dynamic.title("Testing 'sum_triangular_numbers' "
"with negative numbers")
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 negative number and verify the output"):
n = -291
expected = 0

n: int = -291

Check notice on line 52 in kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py#L52

Variable name "n" doesn't conform to snake_case naming style (invalid-name)
expected: int = 0
print_log(n=n, expected=expected)
self.assertEqual(sum_triangular_numbers(n), expected)

with allure.step("Enter negative number and verify the output"):
n = -971
expected = 0

n: int = -971

Check notice on line 58 in kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py#L58

Variable name "n" doesn't conform to snake_case naming style (invalid-name)
expected: int = 0
print_log(n=n, expected=expected)
self.assertEqual(sum_triangular_numbers(n), expected)

Expand All @@ -60,19 +66,19 @@ def test_sum_triangular_numbers_zero(self):
with zero as an input
:return:
"""

# pylint: disable-msg=R0801
allure.dynamic.title("Testing 'sum_triangular_numbers' with zero")
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 zero and verify the output"):
n = 0
expected = 0

n: int = 0

Check notice on line 80 in kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py#L80

Variable name "n" doesn't conform to snake_case naming style (invalid-name)
expected: int = 0
print_log(n=n, expected=expected)
self.assertEqual(sum_triangular_numbers(n), expected)

Expand All @@ -82,29 +88,28 @@ def test_sum_triangular_numbers_positive_numbers(self):
with positive numbers
:return:
"""

# pylint: disable-msg=R0801
allure.dynamic.title("Testing 'sum_triangular_numbers' "
"with positive numbers")
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 positive number as an input "
"and verify the output"):
n = 6
expected = 56

n: int = 6

Check notice on line 104 in kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py#L104

Variable name "n" doesn't conform to snake_case naming style (invalid-name)
expected: int = 56
print_log(n=n, expected=expected)
self.assertEqual(sum_triangular_numbers(n), expected)

with allure.step("Enter a positive number as an input "
"and verify the output"):
n = 34
expected = 7140

n: int = 34

Check notice on line 111 in kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py#L111

Variable name "n" doesn't conform to snake_case naming style (invalid-name)
expected: int = 7140
print_log(n=n, expected=expected)
self.assertEqual(sum_triangular_numbers(n), expected)

Expand All @@ -114,20 +119,20 @@ def test_sum_triangular_numbers_big_number(self):
with big number as an input
:return:
"""

# pylint: disable-msg=R0801
allure.dynamic.title("Testing 'sum_triangular_numbers' "
"with big number as an input")
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 big number as an input "
"and verify the output"):
n = 943
expected = 140205240

n:int = 943

Check notice on line 135 in kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py

View check run for this annotation

codefactor.io / CodeFactor

kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py#L135

Variable name "n" doesn't conform to snake_case naming style (invalid-name)
expected:int = 140205240
print_log(n=n, expected=expected)
self.assertEqual(sum_triangular_numbers(n), expected)

0 comments on commit 04d3354

Please sign in to comment.