Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def on_service_state_change(zeroconf, service_type, state_change, name):
# mock zeroconf's logger warning() and debug()
from unittest.mock import patch

patch_warn = patch('zeroconf.log.warning')
patch_debug = patch('zeroconf.log.debug')
patch_warn = patch('zeroconf._logger.log.warning')
patch_debug = patch('zeroconf._logger.log.debug')
mocked_log_warn = patch_warn.start()
mocked_log_debug = patch_debug.start()

Expand Down
18 changes: 9 additions & 9 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
"""Unit tests for logger.py."""

from unittest.mock import patch
from zeroconf.logger import QuietLogger
from zeroconf._logger import QuietLogger


def test_log_warning_once():
"""Test we only log with warning level once."""
quiet_logger = QuietLogger()
with patch("zeroconf.logger.log.warning") as mock_log_warning, patch(
"zeroconf.logger.log.debug"
with patch("zeroconf._logger.log.warning") as mock_log_warning, patch(
"zeroconf._logger.log.debug"
) as mock_log_debug:
quiet_logger.log_warning_once("the warning")

assert mock_log_warning.mock_calls
assert not mock_log_debug.mock_calls

with patch("zeroconf.logger.log.warning") as mock_log_warning, patch(
"zeroconf.logger.log.debug"
with patch("zeroconf._logger.log.warning") as mock_log_warning, patch(
"zeroconf._logger.log.debug"
) as mock_log_debug:
quiet_logger.log_warning_once("the warning")

Expand All @@ -31,16 +31,16 @@ def test_log_warning_once():
def test_log_exception_warning():
"""Test we only log with warning level once."""
quiet_logger = QuietLogger()
with patch("zeroconf.logger.log.warning") as mock_log_warning, patch(
"zeroconf.logger.log.debug"
with patch("zeroconf._logger.log.warning") as mock_log_warning, patch(
"zeroconf._logger.log.debug"
) as mock_log_debug:
quiet_logger.log_exception_warning("the exception warning")

assert mock_log_warning.mock_calls
assert not mock_log_debug.mock_calls

with patch("zeroconf.logger.log.warning") as mock_log_warning, patch(
"zeroconf.logger.log.debug"
with patch("zeroconf._logger.log.warning") as mock_log_warning, patch(
"zeroconf._logger.log.debug"
) as mock_log_debug:
quiet_logger.log_exception_warning("the exception warning")

Expand Down
2 changes: 1 addition & 1 deletion zeroconf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
DNSService,
DNSText,
)
from ._logger import QuietLogger, log # noqa # import needed for backwards compat
from .exceptions import ( # noqa # import needed for backwards compat
AbstractMethodException,
BadTypeInNameException,
Expand All @@ -45,7 +46,6 @@
NonUniqueNameException,
ServiceNameAlreadyRegistered,
)
from .logger import QuietLogger, log # noqa # import needed for backwards compat
from .services import ( # noqa # import needed for backwards compat
instance_name_from_service_info,
Signal,
Expand Down
2 changes: 1 addition & 1 deletion zeroconf/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from ._dns import DNSIncoming, DNSOutgoing, DNSQuestion
from ._handlers import QueryHandler, RecordManager
from ._logger import QuietLogger, log
from .cache import DNSCache
from .const import (
_CACHE_CLEANUP_INTERVAL,
Expand All @@ -48,7 +49,6 @@
_UNREGISTER_TIME,
)
from .exceptions import NonUniqueNameException
from .logger import QuietLogger, log
from .services import (
RecordUpdateListener,
ServiceBrowser,
Expand Down
2 changes: 1 addition & 1 deletion zeroconf/_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import struct
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Tuple, Union, cast

from ._logger import QuietLogger, log
from .const import (
_CLASSES,
_CLASS_MASK,
Expand All @@ -48,7 +49,6 @@
_TYPE_TXT,
)
from .exceptions import AbstractMethodException, IncomingDecodeError, NamePartTooLongException
from .logger import QuietLogger, log
from .utils.net import _is_v6_address
from .utils.struct import int2byte
from .utils.time import current_time_millis, millis_to_seconds
Expand Down
2 changes: 1 addition & 1 deletion zeroconf/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from typing import List, Optional, TYPE_CHECKING, Union

from ._dns import DNSAddress, DNSIncoming, DNSOutgoing, DNSPointer, DNSQuestion, DNSRecord
from ._logger import log
from .const import (
_CLASS_IN,
_DNS_OTHER_TTL,
Expand All @@ -36,7 +37,6 @@
_TYPE_SRV,
_TYPE_TXT,
)
from .logger import log
from .services import (
RecordUpdateListener,
)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion zeroconf/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
USA
"""

from ._logger import log
from .aio import AsyncZeroconf # pylint: disable=unused-import # noqa
from .logger import log

# The asyncio module would shadow system asyncio in some import cases
# to resolve this, the module has been renamed zeroconf.aio
Expand Down
2 changes: 1 addition & 1 deletion zeroconf/utils/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

import ifaddr

from .._logger import log
from ..const import _IPPROTO_IPV6, _MDNS_ADDR6_BYTES, _MDNS_ADDR_BYTES, _MDNS_PORT
from ..logger import log


@enum.unique
Expand Down