Skip to content

Commit

Permalink
# Help Bob count letters and digits
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 20, 2024
1 parent b0e6da0 commit dbcafc2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
1 change: 1 addition & 0 deletions kyu_7/help_bob_count_letters_and_digits/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Help Bob count letters and digits."""
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""
Solution for -> Help Bob count letters and digits.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def count_letters_and_digits(s: str) -> int:
"""
A method that can determine how many
letters and digits are in a given string.
A method that can determine how many letters and digits are in a given string.
:param s:
:return:
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Help Bob count letters and digits.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from utils.log_func import print_log
from kyu_7.help_bob_count_letters_and_digits.count_letters_and_digits \
import (count_letters_and_digits)
Expand All @@ -25,13 +27,18 @@
url='https://www.codewars.com/kata/5738f5ea9545204cec000155',
name='Source/Kata')
class CalculateTestCase(unittest.TestCase):
"""
Testing count_letters_and_digits function
"""

def test_count_letters_and_digits(self):
"""Testing count_letters_and_digits function."""

@parameterized.expand([
('n!!ice!!123', 7),
('de?=?=tttes!!t', 8),
('', 0),
('!@#$%^&`~.', 0),
('u_n_d_e_r__S_C_O_R_E', 10)])
def test_count_letters_and_digits(self, s, expected):
"""
Testing the function with various test data
Testing the function with various test data.
:return:
"""
# pylint: disable-msg=R0801
Expand All @@ -45,22 +52,9 @@ def test_count_letters_and_digits(self):
"<p>Test a method that can determine how many letters "
"and digits are in a given string.</p>")
# pylint: enable-msg=R0801
test_data: tuple = (
('n!!ice!!123', 7),
('de?=?=tttes!!t', 8),
('', 0),
('!@#$%^&`~.', 0),
('u_n_d_e_r__S_C_O_R_E', 10))

for s, expected in test_data:
actual_result: int = count_letters_and_digits(s)
with allure.step(f"Enter string ({s}) and verify the "
f"expected output ({expected}) vs "
f"actual result ({actual_result})"):

print_log(s=s,
expected=expected,
result=actual_result)

self.assertEqual(expected,
actual_result)
actual_result: int = count_letters_and_digits(s)
with allure.step(f"Enter string ({s}) and verify the "
f"expected output ({expected}) vs "
f"actual result ({actual_result})"):
print_log(s=s, expected=expected,result=actual_result)
self.assertEqual(expected, actual_result)

0 comments on commit dbcafc2

Please sign in to comment.