-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Replace deprecated asynctest
with manual TCP socket
in Thread
#369
Conversation
Time to rebase 😉 |
…read` `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.
The client only connects to `localhost` after all, no need to bind all interfaces.
400a416
to
b8ffb35
Compare
…ection reset by peer")`
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #369 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 343 341 -2
Branches 54 54
=========================================
- Hits 343 341 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ LGTM
Depends on #361 and #365
For #305
asynctest
is unmaintained and deprecated yet there appears to be no clean replacement to mock theasync
methods of anasyncio
client socket, as previously passed toasyncio.open_connection()
. Instead of inventing a complicatedasyncio
solution around this, create and bind asocket
(so that we know the randomly chosen open port upfront) and accept a single client within aThread
. This temporaryThread
closes the connection and can later bejoin()
ed when the test is over to make sure it has finalized and exited.