forked from maxbbraun/trump2cash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs_tests.py
54 lines (36 loc) · 1.03 KB
/
logs_tests.py
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
# -*- coding: utf-8 -*-
from pytest import fixture
from logs import Logs
from logs import LOG_FILE
@fixture
def logs():
# TODO: Test cloud logging.
return Logs("test", to_cloud=False)
def get_last_log():
log_file = open(LOG_FILE, "r")
try:
last_log = log_file.readlines()[-1]
finally:
log_file.close()
return last_log
def test_debug(logs, capfd):
logs.debug("debug")
assert get_last_log().endswith(" DEBUG debug\n")
def test_info(logs, capfd):
logs.info("info")
assert get_last_log().endswith(" INFO info\n")
def test_warn(logs, capfd):
logs.warn("warn")
assert get_last_log().endswith(" WARNING warn\n")
def test_error(logs, capfd):
logs.error("error")
assert get_last_log().endswith(" ERROR error\n")
def test_catch(logs, capfd):
try:
raise Exception("exception")
except Exception as exception:
logs.catch(exception)
assert get_last_log().endswith(" CRITICAL exception\n")
def test_safe_cloud_log(logs):
# TODO: Implement.
pass