From 3d0e085f980562274abd9cf5c1fe880dbdcf9598 Mon Sep 17 00:00:00 2001 From: Gornyh Date: Fri, 13 Mar 2026 15:38:34 +0300 Subject: [PATCH 1/2] Added a test using pytest --- test/test.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/test.py diff --git a/test/test.py b/test/test.py new file mode 100644 index 0000000..dc878c0 --- /dev/null +++ b/test/test.py @@ -0,0 +1,41 @@ +import pytest +from src import sample_hello_world_script as hw + + +def setup_function(function): + """Выполняется перед каждым тестом""" + print(f"\nYou have called setUp() for {function.__name__}") + + +def teardown_function(function): + """Выполняется после каждого теста""" + print(f"You have called tearDown() for {function.__name__}") + + +# --- Тесты --- + +def test_first_function_to_uppercase(): + input_value = 'Venkatt Guhesan' + expected_result = 'VENKATT GUHESAN' + actual_result = hw.first_function_to_uppercase(input_value) + assert actual_result == expected_result + + +def test_upper(): + assert 'foo'.upper() == 'FOO' + + +def test_isupper(): + assert 'FOO'.isupper() + assert not 'Foo'.isupper() + + +def test_split(): + s = 'hello world' + assert s.split() == ['hello', 'world'] + + +def test_split_raises_type_error(): + s = 'hello world' + with pytest.raises(TypeError): + s.split(2) \ No newline at end of file From aa7315ce9b354ba17fcda972d67fb538d7590005 Mon Sep 17 00:00:00 2001 From: Gornyh Date: Fri, 13 Mar 2026 15:51:41 +0300 Subject: [PATCH 2/2] Added a test using pytest --- test/test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test.py b/test/test.py index dc878c0..e1689af 100644 --- a/test/test.py +++ b/test/test.py @@ -3,16 +3,16 @@ def setup_function(function): - """Выполняется перед каждым тестом""" + """Performed before each test""" print(f"\nYou have called setUp() for {function.__name__}") def teardown_function(function): - """Выполняется после каждого теста""" + """Performed after each test""" print(f"You have called tearDown() for {function.__name__}") -# --- Тесты --- +# --- Tests --- def test_first_function_to_uppercase(): input_value = 'Venkatt Guhesan'