Skip to content

0.47.3: pytest warnings with call traces #1133

@kloczek

Description

@kloczek

Looks like something odd happens duting pytest execution and some writes to the tty som call traces.
Thre are as well some pytest warnings.
Here is pytest output:

Details
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-zeroconf-0.47.3-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-zeroconf-0.47.3-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.16, pytest-7.2.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3, configfile: pyproject.toml
plugins: asyncio-0.20.3, xdist-3.2.0
asyncio: mode=strict
collected 269 items

tests/test_asyncio.py ..........................                         [  9%]
tests/test_cache.py ................                                     [ 15%]
tests/test_core.py ......s...................                            [ 25%]
tests/test_dns.py ...........................                            [ 35%]
tests/test_exceptions.py .........                                       [ 38%]
tests/test_handlers.py .........................                         [ 47%]
tests/test_history.py ..                                                 [ 48%]
tests/test_init.py .......                                               [ 51%]
tests/test_logger.py .....                                               [ 53%]
tests/test_protocol.py .............................................     [ 69%]
tests/test_services.py ...                                               [ 71%]
tests/test_updates.py .                                                  [ 71%]
tests/services/test_browser.py .....................                     [ 79%]
tests/services/test_info.py ....................                         [ 86%]
tests/services/test_registry.py ......                                   [ 88%]
tests/services/test_types.py ....                                        [ 90%]
tests/utils/test_asyncio.py .......                                      [ 92%]
tests/utils/test_name.py ...                                             [ 94%]
tests/utils/test_net.py ...........s....                                 [100%]

=============================== warnings summary ===============================
tests/test_asyncio.py::test_async_with_sync_passed_in_closed_in_async
  /usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <coroutine object AsyncEngine._async_setup at 0x7f2e74bd8c40>

  Traceback (most recent call last):
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 1349, in create_datagram_endpoint
      await waiter
  GeneratorExit

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py", line 139, in _async_setup
      await self._async_create_endpoints()
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py", line 159, in _async_create_endpoints
      transport, protocol = await loop.create_datagram_endpoint(lambda: AsyncListener(self.zc), sock=s)
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 1351, in create_datagram_endpoint
      transport.close()
    File "/usr/lib64/python3.8/asyncio/selector_events.py", line 692, in close
      self._loop.call_soon(self._call_connection_lost, None)
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 719, in call_soon
      self._check_closed()
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 508, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_asyncio.py::test_async_service_registration
  /usr/lib64/python3.8/ipaddress.py:44: ResourceWarning: unclosed <socket.socket fd=11, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>
    return IPv4Address(address)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_asyncio.py::test_async_service_registration
  /usr/lib64/python3.8/ipaddress.py:44: ResourceWarning: unclosed <socket.socket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
    return IPv4Address(address)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_asyncio.py::test_async_service_registration
tests/test_core.py::test_guard_against_oversized_packets
tests/test_handlers.py::test_qu_response
  /usr/lib64/python3.8/asyncio/selector_events.py:696: ResourceWarning: unclosed transport <_SelectorDatagramTransport closing fd=11>
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_asyncio.py: 1 warning
tests/test_core.py: 7 warnings
tests/test_handlers.py: 4 warnings
tests/test_init.py: 1 warning
tests/services/test_browser.py: 5 warnings
tests/services/test_info.py: 3 warnings
tests/utils/test_asyncio.py: 1 warning
tests/utils/test_net.py: 1 warning
  /usr/lib64/python3.8/asyncio/base_events.py:654: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
    _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_open_close_twice_from_async
  /usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <coroutine object AsyncEngine._async_setup at 0x7f2e7491d640>

  Traceback (most recent call last):
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 1349, in create_datagram_endpoint
      await waiter
  GeneratorExit

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py", line 139, in _async_setup
      await self._async_create_endpoints()
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py", line 159, in _async_create_endpoints
      transport, protocol = await loop.create_datagram_endpoint(lambda: AsyncListener(self.zc), sock=s)
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 1351, in create_datagram_endpoint
      transport.close()
    File "/usr/lib64/python3.8/asyncio/selector_events.py", line 692, in close
      self._loop.call_soon(self._call_connection_lost, None)
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 719, in call_soon
      self._check_closed()
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 508, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_core.py::test_multiple_sync_instances_stared_from_async_close
  /usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <coroutine object AsyncEngine._async_setup at 0x7f2e747d7040>

  Traceback (most recent call last):
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 1349, in create_datagram_endpoint
      await waiter
  GeneratorExit

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py", line 139, in _async_setup
      await self._async_create_endpoints()
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py", line 159, in _async_create_endpoints
      transport, protocol = await loop.create_datagram_endpoint(lambda: AsyncListener(self.zc), sock=s)
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 1351, in create_datagram_endpoint
      transport.close()
    File "/usr/lib64/python3.8/asyncio/selector_events.py", line 692, in close
      self._loop.call_soon(self._call_connection_lost, None)
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 719, in call_soon
      self._check_closed()
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 508, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_core.py::test_guard_against_oversized_packets
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_dns.py:368: ResourceWarning: unclosed <socket.socket fd=11, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>
    super().__init__(name, type_, class_, ttl, created)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_dns.py:368: ResourceWarning: unclosed <socket.socket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
    super().__init__(name, type_, class_, ttl, created)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_dns.py:368: ResourceWarning: unclosed <socket.socket fd=13, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>
    super().__init__(name, type_, class_, ttl, created)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_dns.py:368: ResourceWarning: unclosed <socket.socket fd=14, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
    super().__init__(name, type_, class_, ttl, created)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_dns.py:368: ResourceWarning: unclosed <socket.socket fd=15, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>
    super().__init__(name, type_, class_, ttl, created)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_dns.py:368: ResourceWarning: unclosed <socket.socket fd=22, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
    super().__init__(name, type_, class_, ttl, created)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_dns.py:368: ResourceWarning: unclosed <socket.socket fd=23, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>
    super().__init__(name, type_, class_, ttl, created)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_dns.py:368: ResourceWarning: unclosed <socket.socket fd=24, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
    super().__init__(name, type_, class_, ttl, created)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /usr/lib64/python3.8/asyncio/selector_events.py:696: ResourceWarning: unclosed transport <_SelectorDatagramTransport closing fd=13>
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /usr/lib64/python3.8/asyncio/selector_events.py:696: ResourceWarning: unclosed transport <_SelectorDatagramTransport closing fd=15>
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_core.py::test_guard_against_oversized_packets
  /usr/lib64/python3.8/asyncio/selector_events.py:696: ResourceWarning: unclosed transport <_SelectorDatagramTransport closing fd=23>
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_exceptions.py::Exceptions::test_invalid_addresses
  /usr/lib64/python3.8/asyncio/tasks.py:922: ResourceWarning: unclosed <socket.socket fd=13, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>
    futures._chain_future(ensure_future(coro, loop=loop), future)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_exceptions.py::Exceptions::test_invalid_addresses
  /usr/lib64/python3.8/asyncio/tasks.py:922: ResourceWarning: unclosed <socket.socket fd=14, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
    futures._chain_future(ensure_future(coro, loop=loop), future)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_handlers.py::test_qu_response
  /usr/lib64/python3.8/selectors.py:74: ResourceWarning: unclosed <socket.socket fd=11, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>
    raise KeyError("{!r} is not registered".format(fileobj)) from None
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_handlers.py::test_qu_response
  /usr/lib64/python3.8/selectors.py:74: ResourceWarning: unclosed <socket.socket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
    raise KeyError("{!r} is not registered".format(fileobj)) from None
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_handlers.py::test_qu_response
  /usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <coroutine object AsyncEngine._async_setup at 0x7f2e748c1a40>

  Traceback (most recent call last):
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 1349, in create_datagram_endpoint
      await waiter
  GeneratorExit

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py", line 139, in _async_setup
      await self._async_create_endpoints()
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py", line 159, in _async_create_endpoints
      transport, protocol = await loop.create_datagram_endpoint(lambda: AsyncListener(self.zc), sock=s)
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 1351, in create_datagram_endpoint
      transport.close()
    File "/usr/lib64/python3.8/asyncio/selector_events.py", line 692, in close
      self._loop.call_soon(self._call_connection_lost, None)
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 719, in call_soon
      self._check_closed()
    File "/usr/lib64/python3.8/asyncio/base_events.py", line 508, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

tests/test_init.py::Names::test_verify_name_change_with_lots_of_names
  /usr/lib64/python3.8/asyncio/selector_events.py:696: ResourceWarning: unclosed transport <_SelectorDatagramTransport fd=11>
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_init.py::Names::test_verify_name_change_with_lots_of_names
  /home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_core.py:159: ResourceWarning: unclosed <socket.socket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
    transport, protocol = await loop.create_datagram_endpoint(lambda: AsyncListener(self.zc), sock=s)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/test_init.py::Names::test_verify_name_change_with_lots_of_names
  /usr/lib64/python3.8/asyncio/selector_events.py:696: ResourceWarning: unclosed transport <_SelectorDatagramTransport fd=12>
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/services/test_browser.py::test_service_browser_listeners_no_update_service
  /usr/lib/python3.8/site-packages/_pytest/threadexception.py:73: PytestUnhandledThreadExceptionWarning: Exception in thread zeroconf-ServiceBrowser-_hap._tcp-1716625

  Traceback (most recent call last):
    File "/usr/lib64/python3.8/threading.py", line 932, in _bootstrap_inner
      self.run()
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_services/browser.py", line 547, in run
      self._fire_service_state_changed_event(event)
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_services/browser.py", line 428, in _fire_service_state_changed_event
      self._service_state_changed.fire(
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_services/__init__.py", line 54, in fire
      h(**kwargs)
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_services/browser.py", line 188, in on_change
      getattr(listener, _ON_CHANGE_DISPATCH[state_change])(zeroconf, service_type, name)
    File "/home/tkloczko/rpmbuild/BUILD/python-zeroconf-0.47.3/src/zeroconf/_services/__init__.py", line 45, in update_service
      raise NotImplementedError()
  NotImplementedError

    warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))

tests/utils/test_net.py::test_disable_ipv6_only_or_raise
  /usr/lib/python3.8/site-packages/_pytest/python.py:200: ResourceWarning: unclosed <socket.socket fd=14, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 0)>
    result = testfunction(**testargs)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/utils/test_net.py::test_add_multicast_member
  /usr/lib64/python3.8/unittest/mock.py:2076: ResourceWarning: unclosed <socket.socket fd=15, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 0)>
    self.name = name
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
SKIPPED [1] tests/test_core.py:154: apple_p2p happy path only testable on mac
SKIPPED [1] tests/utils/test_net.py:136: System has SO_REUSEPORT
=========== 267 passed, 2 skipped, 53 warnings in 106.08s (0:01:46) ============

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions