-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_easy_log.py
More file actions
46 lines (29 loc) · 1016 Bytes
/
test_easy_log.py
File metadata and controls
46 lines (29 loc) · 1016 Bytes
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
import os
from pathlib import Path
def test_easy_debug(load_loguru):
ret = load_loguru({'DEBUG': True})
assert ret['LOGLEVEL'] == 'INFO'
def test_easy_no_debug(load_loguru):
ret = load_loguru({'DEBUG': False})
assert ret['LOGLEVEL'] == 'ERROR'
def test_configure(load_loguru):
log_path = Path(__file__).parent / 'narf.log'
if log_path.exists():
log_path.unlink()
def setup(logger, settings):
logger.add(log_path)
ret = load_loguru({'DEBUG': True}, configure_func=setup)
ret['LOGGER'].info('BARF')
assert log_path.exists()
def test_custom_config(load_loguru):
ret = load_loguru({'DEBUG': False}, logging_config={})
assert len(ret['LOGGING']) == 0
def test_level(load_loguru):
ret = load_loguru({'DEBUG': False}, loglevel="WARNING")
assert ret['LOGLEVEL'] == 'WARNING'
def test_double_load(load_loguru):
try:
ret = load_loguru({'DEBUG': False})
ret = load_loguru({'DEBUG': False})
except Exception as exc:
assert False, f"Raised an exception {exc}"