-
-
Notifications
You must be signed in to change notification settings - Fork 611
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces new context manager `LogContext.intentation()`. Usage: ```python from piptools.loggin import log log.debug("Hello") with log.indentation(): log.debug("World!") ``` Output: ``` Hello World! ```
- Loading branch information
Showing
5 changed files
with
85 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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 (_, stderr): | ||
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", | ||
] |