-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert nh2.mock.expect_connect to a context manager.
Assert that the expected connection has been established before the context manager ends, similar to: mock_server = await nh2.mock.expect_connect(…) conn = await nh2.connection.Connection(…) assert conn.mock_server is mock_server Note that sometimes tests only imply a connection, they don't explicitly set one themselves, as in: async def opaque_workflow(): conn = await nh2.connection.Connection('example.com', 443) async with nh2.anyio_util.create_task_group() as tg: async with nh2.mock.expect_connect('example.com', 443) as mock_server: future = tg.start_soon(opaque_workflow) so expect_connect needs to allow the async system to actually schedule and run backgrounded tasks (which for now is done with just an `anyio.sleep(.01)`). Explicitly reset nh2.mock.expect_connect's cache between runs. See #1.
- Loading branch information
Showing
4 changed files
with
17 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters