diff --git a/kyu_8/century_from_year/__init__.py b/kyu_8/century_from_year/__init__.py index e69de29bb2d..228c0682982 100644 --- a/kyu_8/century_from_year/__init__.py +++ b/kyu_8/century_from_year/__init__.py @@ -0,0 +1 @@ +"""Century From Year.""" diff --git a/kyu_8/century_from_year/century.py b/kyu_8/century_from_year/century.py index b3687eb368f..b6406ec4aa0 100644 --- a/kyu_8/century_from_year/century.py +++ b/kyu_8/century_from_year/century.py @@ -1,5 +1,6 @@ """ -Solution for -> Century From Year +Solution for -> Century From Year. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,7 +8,8 @@ def century(year: int) -> int: """ - Given a year, return the century it is in + Given a year, return the century it is in. + :param year: int :return: int """ diff --git a/kyu_8/century_from_year/test_century.py b/kyu_8/century_from_year/test_century.py index 1c86b9c549c..37cf962a18b 100644 --- a/kyu_8/century_from_year/test_century.py +++ b/kyu_8/century_from_year/test_century.py @@ -1,5 +1,6 @@ """ -Test for -> Century From Year +Test for -> Century From Year. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -9,6 +10,7 @@ import unittest import allure +from parameterized import parameterized from kyu_8.century_from_year.century import century from utils.log_func import print_log @@ -32,45 +34,45 @@ # pylint: enable-msg=R0801 class CenturyTestCase(unittest.TestCase): """ + Testing century function. + The first century spans from the year 1 up to and including the year 100, The second - from the year 101 up to and including the year 200, etc. """ - def test_century(self): + @parameterized.expand([ + (1705, 18, 'Testing for year 1705'), + (1900, 19, 'Testing for year 1900'), + (1601, 17, 'Testing for year 1601'), + (2000, 20, 'Testing for year 2000'), + (356, 4, 'Testing for year 356'), + (89, 1, 'Testing for year 89')]) + def test_century(self, year, expected, message): """ - Testing century function + Testing century function with various test data. + + :return: """ # pylint: disable-msg=R0801 allure.dynamic.title("Testing century function") allure.dynamic.severity(allure.severity_level.NORMAL) allure.dynamic.description_html( '

Codewars badge:

' - '' + '' '

Test Description:

' - "

Given a year, the function should return the century it is in." + "

Given a year, the function should return " + "the century it is in." "

") # pylint: enable-msg=R0801 - test_data: tuple = ( - (1705, 18, 'Testing for year 1705'), - (1900, 19, 'Testing for year 1900'), - (1601, 17, 'Testing for year 1601'), - (2000, 20, 'Testing for year 2000'), - (356, 4, 'Testing for year 356'), - (89, 1, 'Testing for year 89')) - - for year, expected, message in test_data: - result: int = century(year) - - with allure.step(f"Enter test year ({year}) and verify " - f"the output ({result}) " - f"vs expected ({expected})"): - - print_log(year=year, - result=result, - expected=expected, - message=message) - - self.assertEqual(expected, - result) + result: int = century(year) + with allure.step(f"Enter test year ({year}) and verify " + f"the output ({result}) " + f"vs expected ({expected})"): + print_log(year=year, + result=result, + expected=expected, + message=message) + self.assertEqual(expected, result)