Skip to content

Commit

Permalink
stuck atmaking the connect task not None
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Jun 26, 2024
1 parent 7f6cbf4 commit a1baa1f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/core/test_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re
import time
from unittest.mock import ANY
from unittest.mock import ANY, Mock

import numpy
import pytest
Expand Down Expand Up @@ -199,6 +199,27 @@ def fail_connect():
)


async def test_signal_lazily_connects_3(RE):
mock_signal_rw = soft_signal_rw(int, 0, name="mock_signal")
cached_connect = mock_signal_rw._backend.connect
fail_at_first_connect = Mock()
fail_at_first_connect.side_effect = [
Exception("Failure on first call"),
cached_connect,
cached_connect,
]
mock_signal_rw._backend.connect = fail_at_first_connect

with pytest.raises(Exception, match="Failure on first call"):
await mock_signal_rw.connect(mock=False)
RE(ensure_connected(mock_signal_rw, mock=False))
assert (
mock_signal_rw._connect_task
and mock_signal_rw._connect_task.done()
and not mock_signal_rw._connect_task.exception()
)


async def time_taken_by(coro) -> float:
start = time.monotonic()
await coro
Expand Down

0 comments on commit a1baa1f

Please sign in to comment.