Skip to content

Commit 7e467a1

Browse files
committed
Replace asynctest with stdlib mock
The asynctest package is unmaintained since 2020 and incompatible with Python 3.12+. Replace asynctest.TestSelector with a MagicMock using selectors.BaseSelector as its spec, which provides the same mock selector functionality needed by the asyncio reactor tests. Fixes #663
1 parent 3050cf6 commit 7e467a1

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ dev = [
5252
"cython>=3.2",
5353
"packaging>=25.0",
5454
"futurist",
55-
"asynctest",
5655
"pyyaml",
5756
"numpy",
5857
"objgraph",

tests/unit/io/test_asyncioreactor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
AsyncioConnection, ASYNCIO_AVAILABLE = None, False
22
try:
33
from cassandra.io.asyncioreactor import AsyncioConnection
4-
import asynctest
54
ASYNCIO_AVAILABLE = True
65
except (ImportError, SyntaxError, AttributeError):
76
AsyncioConnection = None
@@ -10,8 +9,8 @@
109
from tests import is_monkey_patched, connection_class
1110
from tests.unit.io.utils import TimerCallback, TimerTestMixin
1211

13-
from unittest.mock import patch
14-
12+
from unittest.mock import patch, MagicMock
13+
import selectors
1514
import unittest
1615
import time
1716

@@ -56,7 +55,7 @@ def setUp(self):
5655
socket_patcher.start()
5756

5857
old_selector = AsyncioConnection._loop._selector
59-
AsyncioConnection._loop._selector = asynctest.TestSelector()
58+
AsyncioConnection._loop._selector = MagicMock(spec=selectors.BaseSelector)
6059

6160
def reset_selector():
6261
AsyncioConnection._loop._selector = old_selector

0 commit comments

Comments
 (0)