ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Works as Designed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Background

      test/asynchronous/test_async_network_layer.py has two tests that directly append to protocol._pending_messages (a private deque) to stage state before exercising buffer_updated and close:

      • test_buffer_updated_completes_pending_future (line 105)
      • test_close_with_exception_propagates_to_pending (line 115)

      Problem

      This is white-box coupling to an internal data structure. If _pending_messages is ever replaced with a different internal mechanism (e.g., a dict keyed by request ID), these tests break even though the observable behaviour of PyMongoProtocol is unchanged.

      Fix

      Replace the direct _pending_messages.append(future) setup with calls to protocol.read(), which enqueues the waiter through the public API and makes the tests resilient to internal refactors.

      Discovery

      Found during code review of PR #2774 (coverage increase for network_layer.py).

            Assignee:
            Unassigned
            Reporter:
            Alex Clark
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: