Skip to content

Conversation

@PupiBott
Copy link

@PupiBott PupiBott commented Nov 5, 2025

Fixes #2359

HttpMockSequence is missing the close() method, causing AttributeError
when used with the context manager pattern recommended in the official
documentation.

Root cause: Commit 98888da (Sep 2020) added close() to HttpMock but
forgot to add it to HttpMockSequence.

This PR adds the close() method to HttpMockSequence following the same
no-op pattern as HttpMock.close(), ensuring compatibility with context
manager usage while maintaining backward compatibility.

Changes:

  • Added close() method to HttpMockSequence class
  • Added 5 comprehensive unit tests (100% pass rate)
  • No breaking changes introduced

Testing:
All new tests pass ✅ (5/5 in 0.41s)

Before (fails):
with build('drive', 'v3', http=HttpMockSequence([...])) as service:
pass # AttributeError: 'HttpMockSequence' object has no attribute 'close'

After (works):
with build('drive', 'v3', http=HttpMockSequence([...])) as service:
pass # ✅ Works perfectly

- Add close() method to HttpMockSequence class
- Implements no-op pattern consistent with HttpMock.close()
- Fixes AttributeError when using HttpMockSequence with context manager
- Add 5 comprehensive unit tests covering:
  * Method existence and callability
  * No-op behavior and multiple calls safety
  * Return value consistency (None)
  * Parity with HttpMock.close()
  * Usability after close()

All tests pass (5/5 in 0.33s)

Fixes googleapis#2359

Root cause: Commit 98888da (Sep 2020) added close() to HttpMock but
forgot to add it to HttpMockSequence. This PR completes that implementation.
@PupiBott PupiBott requested review from a team as code owners November 5, 2025 01:21
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpMockSequence is missing close() method

2 participants