-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d10bb3b
commit 084aa66
Showing
8 changed files
with
79 additions
and
30 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
File renamed without changes.
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,11 @@ | ||
import logging | ||
|
||
|
||
log = logging.getLogger('3rd-party') | ||
|
||
|
||
def do_3rd_party_thing(): | ||
log.debug(1) | ||
log.info(2) | ||
log.warning(3) | ||
log.error(4) |
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned,singleton-comparison | ||
|
||
import pytest | ||
|
||
import log | ||
|
||
from . import demo, other | ||
|
||
|
||
def describe_text(): | ||
|
||
def it_includes_the_caller_location(expect, caplog): | ||
demo.greet("caller") | ||
expect(caplog.text) == \ | ||
"demo.py 5 ERROR Hello, caller!\n" | ||
|
||
@pytest.mark.last | ||
def it_can_be_formatted_with_init(expect, caplog): | ||
log.init(format=log.helpers.DEFAULT_FORMAT) | ||
demo.greet("format") | ||
expect(caplog.text) == "ERROR: tests.demo: Hello, format!\n" | ||
|
||
|
||
def describe_silence(): | ||
|
||
def when_off(expect, caplog): | ||
log.silence('3rd-party') | ||
other.do_3rd_party_thing() | ||
expect(caplog.records) == [] | ||
|
||
def with_errors(expect, caplog): | ||
log.silence('3rd-party', allow_error=True) | ||
other.do_3rd_party_thing() | ||
expect(len(caplog.records)) == 1 | ||
|
||
def with_warnings(expect, caplog): | ||
log.silence('3rd-party', allow_warning=True) | ||
other.do_3rd_party_thing() | ||
expect(len(caplog.records)) == 2 | ||
|
||
def with_infos(expect, caplog): | ||
log.silence('3rd-party', allow_info=True) | ||
other.do_3rd_party_thing() | ||
expect(len(caplog.records)) == 3 |