Skip to content

Commit

Permalink
tests: Add logging fix (#4499)
Browse files Browse the repository at this point in the history
Prior to 6bbbfbb, cloud-init's logger was initialized during module
load in cloudinit/log.py and cloudinit/cmd/main.py. Running individual
unittests exposes that many tests assume logging to be configured
automatically as it was before. Configure automatically in conftest.py.
  • Loading branch information
holmanb authored Oct 12, 2023
1 parent a0f53bd commit c84369a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/unittests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from cloudinit import atomic_helper, util
from cloudinit import atomic_helper, log, util
from tests.hypothesis import HAS_HYPOTHESIS
from tests.unittests.helpers import retarget_many_wrapper

Expand Down Expand Up @@ -76,6 +76,8 @@ def side_effect(args, *other_args, **kwargs):
yield


log.configure_root_logger()

PYTEST_VERSION_TUPLE = tuple(map(int, pytest.__version__.split(".")))

if PYTEST_VERSION_TUPLE < (3, 9, 0):
Expand Down
1 change: 0 additions & 1 deletion tests/unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def myaction(name, args):
return "SomeDatasource", ["an error"]

myargs = FakeArgs(("ignored_name", myaction), True, "bogusmode")
log.configure_root_logger()
cli.status_wrapper("init", myargs, data_d, link_d)
# No errors reported in status
status_v1 = m_json.call_args_list[1][0][1]["v1"]
Expand Down

0 comments on commit c84369a

Please sign in to comment.