diff --git a/kyu_6/array_diff/__init__.py b/kyu_6/array_diff/__init__.py index e69de29bb2d..fcd2ecced06 100644 --- a/kyu_6/array_diff/__init__.py +++ b/kyu_6/array_diff/__init__.py @@ -0,0 +1 @@ +"""# Array.diff.""" diff --git a/kyu_6/array_diff/solution.py b/kyu_6/array_diff/solution.py index 9f925b85838..aa96385c3e8 100644 --- a/kyu_6/array_diff/solution.py +++ b/kyu_6/array_diff/solution.py @@ -1,5 +1,6 @@ """ -Solution for -> Array.diff +Solution for -> Array.diff. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ diff --git a/kyu_6/array_diff/test_array_diff.py b/kyu_6/array_diff/test_array_diff.py index ee99d51e5f9..59b2d1538cf 100644 --- a/kyu_6/array_diff/test_array_diff.py +++ b/kyu_6/array_diff/test_array_diff.py @@ -1,5 +1,6 @@ """ -Test for -> Array.diff +Test for -> Array.diff. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -8,6 +9,7 @@ import unittest import allure +from parameterized import parameterized from kyu_6.array_diff.solution import array_diff from utils.log_func import print_log @@ -28,7 +30,7 @@ # pylint: enable-msg=R0801 class ArrayDiffTestCase(unittest.TestCase): """ - Testing array_diff function + Testing array_diff function. Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result. @@ -42,9 +44,16 @@ class ArrayDiffTestCase(unittest.TestCase): array_diff([1,2,2,2,3],[2]) == [1,3] """ - def test_array_diff_function(self): + @parameterized.expand([ + ([1, 2], [1], [2], "a was [1,2], b was [1], expected [2]"), + ([1, 2, 2], [1], [2, 2], "a was [1,2,2], b was [1], expected [2,2]"), + ([1, 2, 2], [2], [1], "a was [1,2,2], b was [2], expected [1]"), + ([1, 2, 2], [], [1, 2, 2], "a was [1,2,2], b was [], expected [1,2,2]"), + ([], [1, 2], [], "a was [], b was [1,2], expected []")]) + def test_array_diff_function(self, a, b, expected, message): """ - Testing array_diff function + Testing array_diff function. + :return: """ # pylint: disable-msg=R0801 @@ -59,29 +68,15 @@ def test_array_diff_function(self): "and returns the result. It should remove all values from " "list a, which are present in list b.

") # pylint: enable-msg=R0801 - test_data: tuple = ( - ([1, 2], [1], [2], "a was [1,2], b was [1], expected [2]"), - ([1, 2, 2], [1], [2, 2], "a was [1,2,2], b was [1], expected [2,2]"), - ([1, 2, 2], [2], [1], "a was [1,2,2], b was [2], expected [1]"), - ([1, 2, 2], [], [1, 2, 2], "a was [1,2,2], b was [], expected [1,2,2]"), - ([], [1, 2], [], "a was [], b was [1,2], expected []")) - - for test_item in test_data: - a: list = test_item[0] - b: list = test_item[1] - expected: list = test_item[2] - message: str = test_item[-1] + with allure.step(f"Enter a test data: {a, b} and verify the " + f"expected output vs actual result: {expected}."): actual_result: list = array_diff(a, b) + print_log(a=a, + b=b, + exp=expected, + message=message, + actual_result=actual_result) - with allure.step("Enter a test data and verify the " - "expected output vs actual result"): - - print_log(a=a, - b=b, - exp=expected, - message=message, - res=actual_result) - - self.assertEqual(expected, - actual_result, - message) + self.assertEqual(expected, + actual_result, + message)