Skip to content

Commit 2ea5d99

Browse files
updating tests
1 parent 8ba7570 commit 2ea5d99

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/unit_tests/connections/batch_async/test_async_ws.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest import main, IsolatedAsyncioTestCase
33

44
from surrealdb.connections.async_ws import AsyncWsSurrealConnection
5+
import sys
56

67

78
class TestAsyncWsSurrealConnection(IsolatedAsyncioTestCase):
@@ -25,11 +26,16 @@ async def asyncSetUp(self):
2526
_ = await self.connection.use(namespace=self.namespace, database=self.database_name)
2627

2728
async def test_batch(self):
28-
async with asyncio.TaskGroup() as tg:
29-
tasks = [tg.create_task(self.connection.query("RETURN sleep(duration::from::millis($d)) or $p**2", dict(d=10 if num%2 else 0, p=num))) for num in range(5)]
29+
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
30+
if python_version == "3.9" or python_version == "3.10":
31+
print("async batching is being bypassed due to python versions 3.9 and 3.10 not supporting async task group")
32+
else:
33+
async with asyncio.TaskGroup() as tg:
34+
tasks = [tg.create_task(self.connection.query("RETURN sleep(duration::from::millis($d)) or $p**2", dict(d=10 if num%2 else 0, p=num))) for num in range(5)]
35+
36+
outcome = [t.result() for t in tasks]
37+
self.assertEqual([0, 1, 4, 9, 16], outcome)
3038

31-
outcome = [t.result() for t in tasks]
32-
self.assertEqual([0, 1, 4, 9, 16], outcome)
3339

3440

3541
if __name__ == "__main__":

0 commit comments

Comments
 (0)