pytak icon indicating copy to clipboard operation
pytak copied to clipboard

Aligning with asyncio recommendations in test

Open allrob23 opened this issue 8 months ago • 0 comments

Hello, Im doing research on asyncio best practices, I noticed that the test test_eventworker directly instantiates a StreamWriter, while the official documentation suggests:

It is not recommended to instantiate StreamReader objects directly; use open_connection() and start_server() instead.

I understand that for testing purposes this approach works well and does not cause any real issues. However, I'd like to suggest a small refactoring using mocks with the appropriate specs and the open_connection() function, which maintains the same test coverage while aligning with recommended practices.

What do you think of this approach? It's a minor change that could serve as an example of best practices for future contributors, but I'm open to feedback.

allrob23 avatar Apr 24 '25 12:04 allrob23