Skip to content

Commit 8218355

Browse files
committed
CI fixes
1 parent e077622 commit 8218355

File tree

3 files changed

+20
-31
lines changed

3 files changed

+20
-31
lines changed

streamz/tests/py3_test_core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# flake8: noqa
2+
import asyncio
23
from time import time
3-
from distributed.utils_test import loop, inc # noqa
4-
from tornado import gen
4+
from distributed.utils_test import inc # noqa
55

66
from streamz import Stream
77

88

9-
def test_await_syntax(loop): # noqa
9+
def test_await_syntax(): # noqa
1010
L = []
1111

1212
async def write(x):
13-
await gen.sleep(0.1)
13+
await asyncio.sleep(0.1)
1414
L.append(x)
1515

1616
async def f():
@@ -25,4 +25,4 @@ async def f():
2525
assert 0.2 < stop - start < 0.4
2626
assert 2 <= len(L) <= 4
2727

28-
loop.run_sync(f)
28+
asyncio.run(f())

streamz/tests/test_core.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
from datetime import timedelta
23
from functools import partial
34
import itertools
@@ -12,14 +13,15 @@
1213

1314
from tornado.queues import Queue
1415
from tornado.ioloop import IOLoop
16+
from tornado import gen
1517

1618
import streamz as sz
1719

1820
from streamz import RefCounter
1921
from streamz.sources import sink_to_file
2022
from streamz.utils_test import (inc, double, gen_test, tmpfile, captured_logger, # noqa: F401
2123
clean, await_for, metadata, wait_for) # noqa: F401
22-
from distributed.utils_test import loop # noqa: F401
24+
from distributed.utils_test import loop, loop_in_thread, cleanup # noqa: F401
2325

2426

2527
def test_basic():
@@ -1485,37 +1487,13 @@ def dont_test_stream_kwargs(clean): # noqa: F811
14851487
sin.emit(1)
14861488

14871489

1488-
@pytest.fixture
1489-
def thread(loop): # noqa: F811
1490-
from threading import Thread, Event
1491-
thread = Thread(target=loop.start)
1492-
thread.daemon = True
1493-
thread.start()
1494-
1495-
event = Event()
1496-
loop.add_callback(event.set)
1497-
event.wait()
1498-
1499-
return thread
1500-
1501-
15021490
def test_percolate_loop_information(clean): # noqa: F811
15031491
source = Stream()
15041492
assert not source.loop
15051493
s = source.timed_window(0.5)
15061494
assert source.loop is s.loop
15071495

15081496

1509-
def test_separate_thread_without_time(loop, thread): # noqa: F811
1510-
assert thread.is_alive()
1511-
source = Stream(loop=loop)
1512-
L = source.map(inc).sink_to_list()
1513-
1514-
for i in range(10):
1515-
source.emit(i)
1516-
assert L[-1] == i + 1
1517-
1518-
15191497
def test_separate_thread_with_time(clean): # noqa: F811
15201498
L = []
15211499

streamz/tests/test_dask.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
from distributed import Future, Client
1515
from distributed.utils import sync
16-
from distributed.utils_test import gen_cluster, inc, cluster, loop, slowinc # noqa: F401
16+
from distributed.utils_test import gen_cluster, loop, loop_in_thread, cleanup, inc, cluster, loop, slowinc # noqa: F401
1717

1818

19+
@pytest.mark.asyncio
1920
@gen_cluster(client=True)
2021
async def test_map(c, s, a, b):
2122
source = Stream(asynchronous=True)
@@ -30,6 +31,7 @@ async def test_map(c, s, a, b):
3031
assert all(isinstance(f, Future) for f in futures_L)
3132

3233

34+
@pytest.mark.asyncio
3335
@gen_cluster(client=True)
3436
async def test_map_on_dict(c, s, a, b):
3537
# dask treats dicts differently, so we have to make sure
@@ -52,6 +54,7 @@ def add_to_dict(d):
5254
assert item["i"] == i
5355

5456

57+
@pytest.mark.asyncio
5558
@gen_cluster(client=True)
5659
async def test_partition_then_scatter_async(c, s, a, b):
5760
# Ensure partition w/ timeout before scatter works correctly for
@@ -92,6 +95,7 @@ def test_partition_then_scatter_sync(loop):
9295
assert L == [1, 2, 3]
9396

9497

98+
@pytest.mark.asyncio
9599
@gen_cluster(client=True)
96100
async def test_non_unique_emit(c, s, a, b):
97101
"""Regression for https://github.com/python-streamz/streams/issues/397
@@ -110,6 +114,7 @@ async def test_non_unique_emit(c, s, a, b):
110114
assert L[0] != L[1] or L[0] != L[2]
111115

112116

117+
@pytest.mark.asyncio
113118
@gen_cluster(client=True)
114119
async def test_scan(c, s, a, b):
115120
source = Stream(asynchronous=True)
@@ -124,6 +129,7 @@ async def test_scan(c, s, a, b):
124129
assert all(isinstance(f, Future) for f in futures_L)
125130

126131

132+
@pytest.mark.asyncio
127133
@gen_cluster(client=True)
128134
async def test_scan_state(c, s, a, b):
129135
source = Stream(asynchronous=True)
@@ -139,6 +145,7 @@ def f(acc, i):
139145
assert L == [0, 1, 3]
140146

141147

148+
@pytest.mark.asyncio
142149
@gen_cluster(client=True)
143150
async def test_zip(c, s, a, b):
144151
a = Stream(asynchronous=True)
@@ -155,6 +162,7 @@ async def test_zip(c, s, a, b):
155162
assert L == [(1, 'a'), (2, 'b')]
156163

157164

165+
@pytest.mark.asyncio
158166
@gen_cluster(client=True)
159167
async def test_accumulate(c, s, a, b):
160168
source = Stream(asynchronous=True)
@@ -192,6 +200,7 @@ def test_sync_2(loop): # noqa: F811
192200
assert L == list(map(inc, range(10)))
193201

194202

203+
@pytest.mark.asyncio
195204
@gen_cluster(client=True, nthreads=[('127.0.0.1', 1)] * 2)
196205
async def test_buffer(c, s, a, b):
197206
source = Stream(asynchronous=True)
@@ -241,6 +250,7 @@ def test_buffer_sync(loop): # noqa: F811
241250
assert L == list(map(inc, range(10)))
242251

243252

253+
@pytest.mark.asyncio
244254
@pytest.mark.xfail(reason='')
245255
async def test_stream_shares_client_loop(loop): # noqa: F811
246256
with cluster() as (s, [a, b]):
@@ -250,6 +260,7 @@ async def test_stream_shares_client_loop(loop): # noqa: F811
250260
assert source.loop is client.loop
251261

252262

263+
@pytest.mark.asyncio
253264
@gen_cluster(client=True)
254265
async def test_starmap(c, s, a, b):
255266
def add(x, y, z=0):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy