Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ dev = [
"cython>=3.2",
"packaging>=25.0",
"futurist",
"asynctest",
"pyyaml",
"numpy",
"objgraph",
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/io/test_asyncioreactor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
AsyncioConnection, ASYNCIO_AVAILABLE = None, False
try:
from cassandra.io.asyncioreactor import AsyncioConnection
import asynctest
ASYNCIO_AVAILABLE = True
except (ImportError, SyntaxError, AttributeError):
AsyncioConnection = None
Expand All @@ -10,8 +9,8 @@
from tests import is_monkey_patched, connection_class
from tests.unit.io.utils import TimerCallback, TimerTestMixin

from unittest.mock import patch

from unittest.mock import patch, MagicMock
import selectors
import unittest
import time

Expand Down Expand Up @@ -56,7 +55,7 @@ def setUp(self):
socket_patcher.start()

old_selector = AsyncioConnection._loop._selector
AsyncioConnection._loop._selector = asynctest.TestSelector()
AsyncioConnection._loop._selector = MagicMock(spec=selectors.BaseSelector)

def reset_selector():
AsyncioConnection._loop._selector = old_selector
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ def submit_and_wait_for_completion(unit_test, create_timer, start, end, incremen
time.sleep(.1)

# ensure they are all called back in a timely fashion
# Use a generous tolerance (500ms) to account for CI environments under heavy load,
# especially Windows during wheel building where timing can be significantly less precise
for callback in completed_callbacks:
assert callback.expected_wait == pytest.approx(callback.get_wait_time(), abs=.15)
assert callback.expected_wait == pytest.approx(callback.get_wait_time(), abs=.5)


def noop_if_monkey_patched(f):
Expand Down
Loading