diff --git a/pymongo/asynchronous/topology.py b/pymongo/asynchronous/topology.py index 2df30d244f..8a46e7fecd 100644 --- a/pymongo/asynchronous/topology.py +++ b/pymongo/asynchronous/topology.py @@ -475,7 +475,7 @@ async def _process_change( if server: await server.pool.ready() - suppress_event = (self._publish_server or self._publish_tp) and sd_old == server_description + suppress_event = sd_old == server_description if self._publish_server and not suppress_event: assert self._events is not None self._events.put( @@ -497,7 +497,7 @@ async def _process_change( (td_old, self._description, self._topology_id), ) ) - if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): + if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event: _debug_log( _SDAM_LOGGER, topologyId=self._topology_id, diff --git a/pymongo/synchronous/topology.py b/pymongo/synchronous/topology.py index 54a9d8a69e..9932d2cbd9 100644 --- a/pymongo/synchronous/topology.py +++ b/pymongo/synchronous/topology.py @@ -475,7 +475,7 @@ def _process_change( if server: server.pool.ready() - suppress_event = (self._publish_server or self._publish_tp) and sd_old == server_description + suppress_event = sd_old == server_description if self._publish_server and not suppress_event: assert self._events is not None self._events.put( @@ -497,7 +497,7 @@ def _process_change( (td_old, self._description, self._topology_id), ) ) - if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): + if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event: _debug_log( _SDAM_LOGGER, topologyId=self._topology_id, diff --git a/test/unified_format.py b/test/unified_format.py index 99fe0b1693..e4ebf677e2 100644 --- a/test/unified_format.py +++ b/test/unified_format.py @@ -1954,7 +1954,11 @@ def format_logs(log_list): if client.get("ignoreExtraMessages", False): actual_logs = actual_logs[: len(client["messages"])] - self.assertEqual(len(client["messages"]), len(actual_logs)) + self.assertEqual( + len(client["messages"]), + len(actual_logs), + f"expected {client['messages']} but got {actual_logs}", + ) for expected_msg, actual_msg in zip(client["messages"], actual_logs): expected_data, actual_data = expected_msg.pop("data"), actual_msg.pop("data")