Skip to content

Commit 9851097

Browse files
authored
Speed up test_socket_error_dupe and test_socket_error_default tests (#573)
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.
1 parent c28e1c1 commit 9851097

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

aiosmtpd/tests/test_server.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ def test_reuse_loop(self, temp_event_loop):
213213
@pytest.mark.skipif(in_wsl(), reason="WSL prevents socket collision")
214214
def test_socket_error_dupe(self, plain_controller, client):
215215
contr2 = Controller(
216-
Sink(), hostname=Global.SrvAddr.host, port=Global.SrvAddr.port
216+
Sink(),
217+
hostname=Global.SrvAddr.host,
218+
port=Global.SrvAddr.port,
219+
ready_timeout=0.5,
217220
)
218221
expectedre = r"error while attempting to bind on address"
219222
try:
@@ -225,7 +228,10 @@ def test_socket_error_dupe(self, plain_controller, client):
225228
@pytest.mark.skipif(in_wsl(), reason="WSL prevents socket collision")
226229
def test_socket_error_default(self):
227230
contr1 = Controller(Sink())
228-
contr2 = Controller(Sink())
231+
contr2 = Controller(
232+
Sink(),
233+
ready_timeout=0.5,
234+
)
229235
expectedre = r"error while attempting to bind on address"
230236
try:
231237
with pytest.raises(socket.error, match=expectedre):

0 commit comments

Comments
 (0)