-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Replace deprecated
asynctest
with manual TCP socket
in `Th…
…read` (#369) * tests: Replace deprecated `asynctest` with manual TCP `socket` in `Thread` `asynctest` is unmaintained and deprecated yet there appears to be no clean replacement to mock the `async` methods of an `asyncio` client socket, as previously passed to `asyncio.open_connection()`. Instead of inventing a complicated `asyncio` solution around this, create and bind a `socket` (so that we know the randomly chosen open port upfront) and accept a single client within a `Thread`. This temporary `Thread` closes the connection and can later be `join()`ed when the test is over to make sure it has finalized and exited. * test_tcp_models: Always `shutdown()` socket before `close()` * Allow typechecker union syntax by importing `__future__.annotations` * test_tcp_models: Only bind server to `localhost` The client only connects to `localhost` after all, no need to bind all interfaces. * test_tcp_models: Enable linger with 0-timeout to force `OSError("Connection reset by peer")`
- Loading branch information
Showing
4 changed files
with
150 additions
and
134 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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