forked from jazzband/pip-tools
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_logging.py
More file actions
28 lines (23 loc) · 758 Bytes
/
Copy pathtest_logging.py
File metadata and controls
28 lines (23 loc) · 758 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
from __future__ import annotations
from piptools.logging import LogContext
def test_indentation(runner):
"""
Test LogContext.indentation() context manager increases indentation.
"""
log = LogContext(indent_width=2)
with runner.isolation() as streams:
stderr = streams[1]
log.log("Test message 1")
with log.indentation():
log.log("Test message 2")
with log.indentation():
log.log("Test message 3")
log.log("Test message 4")
log.log("Test message 5")
assert stderr.getvalue().decode().splitlines() == [
"Test message 1",
" Test message 2",
" Test message 3",
" Test message 4",
"Test message 5",
]