We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ef8f7cd + be1ff4a commit d32b09cCopy full SHA for d32b09c
exercises/024-class-with-two-methods/test.py
@@ -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