Skip to content

Commit d32b09c

Browse files
authored
Merge pull request #69 from AnggieAlava/bug/024
Test agregado ejercicio 024
2 parents ef8f7cd + be1ff4a commit d32b09c

File tree

1 file changed

+26
-0
lines changed
  • exercises/024-class-with-two-methods

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import pytest
2+
import os
3+
import re
4+
import io
5+
import sys
6+
import mock
7+
8+
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
9+
10+
11+
@pytest.mark.it('Use the function print()')
12+
def test_for_file_output(capsys):
13+
with open(path, 'r') as content_file:
14+
content = content_file.read()
15+
pattern = (r"print\s*\(")
16+
regex = re.compile(pattern)
17+
assert bool(regex.search(content)) == True
18+
19+
20+
@pytest.mark.it("String input should be uppercase")
21+
@mock.patch('builtins.input', lambda x: 'hello')
22+
def test_plus_ten(stdin):
23+
sys.stdout = buffer = io.StringIO()
24+
import app
25+
captured = buffer.getvalue()
26+
assert "HELLO\n" in captured

0 commit comments

Comments
 (0)