Skip to content

Commit

Permalink
Update test_valid_parentheses.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 13, 2024
1 parent 6ab8cf3 commit 1df955a
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions kyu_5/valid_parentheses/test_valid_parentheses.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import unittest
import allure
from parameterized import parameterized

from kyu_5.valid_parentheses.valid_parentheses \
import valid_parentheses
from utils.log_func import print_log
Expand All @@ -29,20 +31,25 @@
class ValidParenthesesTestCase(unittest.TestCase):
"""Testing valid_parentheses function."""

def test_valid_parentheses(self):
@parameterized.expand([
(" (", False),
(")test", False),
("", True),
("hi())(", False),
("hi(hi)()", True),
("()", True),
(")(()))", False),
("(", False),
("(())((()())())", True)
])
def test_valid_parentheses(self, test_input, expected):
"""
Testing valid_parentheses with various test data.
Test the valid_parentheses function that takes a string
of parentheses, and determines if the order of the
parentheses is valid. The function should return true
if the string is valid, and false if it's invalid.
Examples:
"()" => true
")(()))" => false
"(" => false
"(())((()())())" => true
:return:
"""
# pylint: disable-msg=R0801
Expand All @@ -55,20 +62,7 @@ def test_valid_parentheses(self):
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable-msg=R0801
with allure.step("Enter test string and verify the output"):
test_data: tuple = (
(" (", False),
(")test", False),
("", True),
("hi())(", False),
("hi(hi)()", True),
("()", True),
(")(()))", False),
("(", False),
("(())((()())())", True))

for string, expected in test_data:
print_log(string=string,
expected=expected)
self.assertEqual(expected,
valid_parentheses(string))
with allure.step(f"Enter test string: {test_input}"
f"and verify the expected output: {expected}."):
print_log(test_input=test_input, expected=expected)
self.assertEqual(expected, valid_parentheses(test_input))

0 comments on commit 1df955a

Please sign in to comment.