From be1ff4a8268de8df88f8559393b9d47817f83ebb Mon Sep 17 00:00:00 2001 From: Anggie Alava <131820456+AnggieAlava@users.noreply.github.com> Date: Thu, 7 Mar 2024 20:24:15 +0000 Subject: [PATCH] Test agregado ejercicio 024 --- exercises/024-class-with-two-methods/test.py | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 exercises/024-class-with-two-methods/test.py diff --git a/exercises/024-class-with-two-methods/test.py b/exercises/024-class-with-two-methods/test.py new file mode 100644 index 00000000..b722f068 --- /dev/null +++ b/exercises/024-class-with-two-methods/test.py @@ -0,0 +1,26 @@ +import pytest +import os +import re +import io +import sys +import mock + +path = os.path.dirname(os.path.abspath(__file__))+'/app.py' + + +@pytest.mark.it('Use the function print()') +def test_for_file_output(capsys): + with open(path, 'r') as content_file: + content = content_file.read() + pattern = (r"print\s*\(") + regex = re.compile(pattern) + assert bool(regex.search(content)) == True + + +@pytest.mark.it("String input should be uppercase") +@mock.patch('builtins.input', lambda x: 'hello') +def test_plus_ten(stdin): + sys.stdout = buffer = io.StringIO() + import app + captured = buffer.getvalue() + assert "HELLO\n" in captured