From 61e7415a16b4817b0ef3707b6fb0f75222d2f5cd Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sat, 14 Dec 2024 09:49:47 -0800 Subject: [PATCH] Update test_increment_string.py --- .../test_increment_string.py | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/kyu_5/string_incrementer/test_increment_string.py b/kyu_5/string_incrementer/test_increment_string.py index e6f40241467..7fdad745c48 100644 --- a/kyu_5/string_incrementer/test_increment_string.py +++ b/kyu_5/string_incrementer/test_increment_string.py @@ -10,6 +10,7 @@ import unittest import allure +from parameterized import parameterized from utils.log_func import print_log from kyu_5.string_incrementer.string_incrementer \ import increment_string @@ -35,7 +36,17 @@ class StringIncrementerTestCase(unittest.TestCase): """Testing increment_string function.""" - def test_increment_string(self): + @parameterized.expand([ + ("foo", "foo1"), + ("foobar001", "foobar002"), + ("foobar1", "foobar2"), + ("foobar00", "foobar01"), + ("foobar99", "foobar100"), + ("foobar099", "foobar100"), + ("", "1"), + ('009', '010'), + ('^0000007', '^0000008')]) + def test_increment_string(self, string, expected): """ Testing a function named increment_string. @@ -56,21 +67,8 @@ def test_increment_string(self): "should be appended to the new string." "

") # pylint: enable-msg=R0801 - test_data: tuple = ( - ("foo", "foo1"), - ("foobar001", "foobar002"), - ("foobar1", "foobar2"), - ("foobar00", "foobar01"), - ("foobar99", "foobar100"), - ("foobar099", "foobar100"), - ("", "1"), - ('009', '010'), - ('^0000007', '^0000008')) - - for sting, expected in test_data: - with allure.step("Enter test string and verify the output"): - result = increment_string(sting) - print_log(string=sting, - expected=expected, - result=result) - self.assertEqual(expected, result) + with allure.step(f"Enter test string: {string} " + f"and verify the output: {expected}"): + result = increment_string(string) + print_log(string=string, expected=expected, result=result) + self.assertEqual(expected, result)