forked from canonical/cloud-init
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Pass deprecation log args as tuple (canonical#5953)
The previous way was preventing passing multiple (or no) args.
- Loading branch information
1 parent
4d559e7
commit 07db0da
Showing
3 changed files
with
36 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import logging | ||
|
||
import pytest | ||
|
||
from cloudinit import lifecycle | ||
|
||
LOG = logging.getLogger() | ||
|
||
|
||
class TestLogWithDowngradableLevel: | ||
@pytest.mark.parametrize( | ||
"version,expected", | ||
[ | ||
("9", logging.ERROR), | ||
("11", logging.DEBUG), | ||
], | ||
) | ||
def test_log_with_downgradable_level( | ||
self, mocker, caplog, version, expected | ||
): | ||
mocker.patch("cloudinit.features.DEPRECATION_INFO_BOUNDARY", "10") | ||
lifecycle.log_with_downgradable_level( | ||
logger=LOG, | ||
version=version, | ||
requested_level=logging.ERROR, | ||
msg="look at me %s %s!", | ||
args=("one", "two"), | ||
) | ||
records = caplog.record_tuples | ||
assert len(records) == 1 | ||
assert records[0][1] == expected | ||
assert records[0][2] == "look at me one two!" |