Skip to content

Speed up test_socket_error_dupe and test_socket_error_default tests#573

Open
cuu508 wants to merge 1 commit intoaio-libs:masterfrom
cuu508:speed_up_bind_error_tests
Open

Speed up test_socket_error_dupe and test_socket_error_default tests#573
cuu508 wants to merge 1 commit intoaio-libs:masterfrom
cuu508:speed_up_bind_error_tests

Conversation

@cuu508
Copy link
Copy Markdown
Contributor

@cuu508 cuu508 commented Apr 27, 2026

What do these changes do?

Controller.start() starts a thread and waits for a ready event for 5 seconds (aiosmtpd.controller.DEFAULT_READY_TIMEOUT). If the thread hits an exception, the ready event never comes. The test_socket_error_dupe and test_socket_error_default tests exercise this scenario, and so each takes full 5 seconds to run. I updated these two tests to pass in a shorter ready_timeout value so they don't hang for as long. This saves ~9 seconds for a full test suite run, per environment.

Are there changes in behavior for the user?

No, they just speed up tests.

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • tox testenvs have been executed in the following environments:
    • Linux (Ubuntu 18.04, Ubuntu 20.04, Arch): {py36,py37,py38,py39}-{nocov,cov,diffcov}, qa, docs
    • Windows (7, 10): {py36,py37,py38,py39}-{nocov,cov,diffcov}
    • WSL 1.0 (Ubuntu 18.04): {py36,py37,py38,py39}-{nocov,cov,diffcov}, pypy3-{nocov,cov}, qa, docs
    • FreeBSD (12.2, 12.1, 11.4): {py36,pypy3}-{nocov,cov,diffcov}, qa
    • Cygwin: py36-{nocov,cov,diffcov}, qa, docs
    • Ubuntu 24.04, py310
  • Documentation reflects the changes
  • Add a news fragment into the NEWS.rst file

Controller.start() starts a thread and waits for a ready event
for 5 seconds (aiosmtpd.controller.DEFAULT_READY_TIMEOUT).
If the thread hits an exception, the ready event never comes.
The `test_socket_error_dupe` and `test_socket_error_default` tests
exercise this scenario, and so each takes full 5 seconds to run.
I updated these two tests to pass in a shorter ready_timeout value
so they don't hang for as long. This saves ~9 seconds for
a full test suite run, per environment.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (a55d3de) to head (b5c876c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #573      +/-   ##
==========================================
- Coverage   97.86%   97.84%   -0.02%     
==========================================
  Files          23       23              
  Lines        5701     5701              
  Branches      766      766              
==========================================
- Hits         5579     5578       -1     
- Misses         77       79       +2     
+ Partials       45       44       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant