From 04d33547e6c2db504bf3493fcf7c58542935e13c Mon Sep 17 00:00:00 2001 From: Egor Kostan Date: Mon, 23 Sep 2024 20:49:20 -0700 Subject: [PATCH] ==kyu_7.sum_of_triangular_numbers 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('

Codewars badge:

' '' '

Test Description:

' "

") (duplicate-code) --- .../sum_triangular_numbers.py | 11 +- .../test_sum_triangular_numbers.py | 109 +++++++++--------- 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/kyu_7/sum_of_triangular_numbers/sum_triangular_numbers.py b/kyu_7/sum_of_triangular_numbers/sum_triangular_numbers.py index cef56de7c35..05eb3716e7e 100644 --- a/kyu_7/sum_of_triangular_numbers/sum_triangular_numbers.py +++ b/kyu_7/sum_of_triangular_numbers/sum_triangular_numbers.py @@ -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: @@ -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) diff --git a/kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py b/kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py index 883ffb0117a..af8737b79c4 100644 --- a/kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py +++ b/kyu_7/sum_of_triangular_numbers/test_sum_triangular_numbers.py @@ -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 @@ -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 @@ -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('

Codewars badge:

' - '' - '

Test Description:

' - "

") - + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

") + # pylint: enable-msg=R0801 with allure.step("Enter negative number and verify the output"): - n = -291 - expected = 0 - + n: int = -291 + 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 + expected: int = 0 print_log(n=n, expected=expected) self.assertEqual(sum_triangular_numbers(n), expected) @@ -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('

Codewars badge:

' - '' - '

Test Description:

' - "

") - + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

") + # pylint: enable-msg=R0801 with allure.step("Enter zero and verify the output"): - n = 0 - expected = 0 - + n: int = 0 + expected: int = 0 print_log(n=n, expected=expected) self.assertEqual(sum_triangular_numbers(n), expected) @@ -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('

Codewars badge:

' - '' - '

Test Description:

' - "

") - + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

") + # 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 + 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 + expected: int = 7140 print_log(n=n, expected=expected) self.assertEqual(sum_triangular_numbers(n), expected) @@ -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('

Codewars badge:

' - '' - '

Test Description:

' - "

") - + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

") + # 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 + expected:int = 140205240 print_log(n=n, expected=expected) self.assertEqual(sum_triangular_numbers(n), expected)