forked from alexysxeightn/MADE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_repeater.py
More file actions
63 lines (51 loc) · 2.03 KB
/
Copy pathtest_repeater.py
File metadata and controls
63 lines (51 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pytest
from task_repeater import (
verbose_context, verbose, repeater
)
def test_repeater_work_correct(capsys):
@repeater(5)
def print_test_message():
"""doc_string for print_test_message"""
print("Test message")
print_test_message()
captured = capsys.readouterr().out.strip().split('\n')
assert 5 * ["Test message"] == captured
assert "doc_string for print_test_message" == print_test_message.__doc__
assert "print_test_message" == print_test_message.__name__
def test_verbose_work_correct(capsys):
@verbose
def print_test_message():
"""doc_string for print_test_message"""
print("Test message")
print_test_message()
correct_answer = ['before function call', 'Test message', 'after function call']
captured = capsys.readouterr().out.strip().split('\n')
assert correct_answer == captured
assert "doc_string for print_test_message" == print_test_message.__doc__
assert "print_test_message" == print_test_message.__name__
def test_class_verbose_context_work_correct(capsys):
@verbose_context()
def print_test_message():
"""doc_string for print_test_message"""
print("Test message")
print_test_message()
correct_answer = ['class: before function call', 'Test message', 'class: after function call']
captured = capsys.readouterr().out.strip().split('\n')
assert correct_answer == captured
assert "doc_string for print_test_message" == print_test_message.__doc__
assert "print_test_message" == print_test_message.__name__
def test_all_decorator_together_work_correct(capsys):
@verbose_context()
@repeater(4)
@verbose
def print_test_message():
"""doc_string for print_test_message"""
print("Test message")
print_test_message()
correct_answer = ['class: before function call'] + \
4 * ['before function call', 'Test message', 'after function call'] + \
['class: after function call']
captured = capsys.readouterr().out.strip().split('\n')
assert correct_answer == captured
assert "doc_string for print_test_message" == print_test_message.__doc__
assert "print_test_message" == print_test_message.__name__