8
8
from zarr .sync import SyncError , SyncMixin , _get_lock , _get_loop , sync
9
9
from zarr .testing .utils import IS_WASM
10
10
11
+ pytestmark = pytest .mark .skipif (IS_WASM , reason = "Can't test async code in WASM" )
12
+
11
13
12
14
@pytest .fixture (params = [True , False ])
13
15
def sync_loop (request ) -> asyncio .AbstractEventLoop | None :
@@ -18,7 +20,6 @@ def sync_loop(request) -> asyncio.AbstractEventLoop | None:
18
20
return None
19
21
20
22
21
- @pytest .mark .skipif (IS_WASM , reason = "Can't start new threads in WASM" )
22
23
def test_get_loop () -> None :
23
24
# test that calling _get_loop() twice returns the same loop
24
25
loop = _get_loop ()
@@ -33,22 +34,19 @@ def test_get_lock() -> None:
33
34
assert lock is lock2
34
35
35
36
36
- @pytest .mark .skipif (IS_WASM , reason = "Can't test async code in WASM" )
37
37
def test_sync (sync_loop : asyncio .AbstractEventLoop | None ) -> None :
38
38
foo = AsyncMock (return_value = "foo" )
39
39
assert sync (foo (), loop = sync_loop ) == "foo"
40
40
foo .assert_awaited_once ()
41
41
42
42
43
- @pytest .mark .skipif (IS_WASM , reason = "Can't test async code in WASM" )
44
43
def test_sync_raises (sync_loop : asyncio .AbstractEventLoop | None ) -> None :
45
44
foo = AsyncMock (side_effect = ValueError ("foo-bar" ))
46
45
with pytest .raises (ValueError , match = "foo-bar" ):
47
46
sync (foo (), loop = sync_loop )
48
47
foo .assert_awaited_once ()
49
48
50
49
51
- @pytest .mark .skipif (IS_WASM , reason = "Can't test async code in WASM" )
52
50
def test_sync_timeout () -> None :
53
51
duration = 0.002
54
52
@@ -59,7 +57,6 @@ async def foo() -> None:
59
57
sync (foo (), timeout = duration / 2 )
60
58
61
59
62
- @pytest .mark .skipif (IS_WASM , reason = "Can't test async code in WASM" )
63
60
def test_sync_raises_if_no_coroutine (sync_loop : asyncio .AbstractEventLoop | None ) -> None :
64
61
def foo () -> str :
65
62
return "foo"
@@ -68,7 +65,6 @@ def foo() -> str:
68
65
sync (foo (), loop = sync_loop )
69
66
70
67
71
- @pytest .mark .skipif (IS_WASM , reason = "Can't start new threads in WASM" )
72
68
@pytest .mark .filterwarnings ("ignore:coroutine.*was never awaited" )
73
69
def test_sync_raises_if_loop_is_closed () -> None :
74
70
loop = _get_loop ()
@@ -104,7 +100,6 @@ def test_sync_raises_if_loop_is_invalid_type() -> None:
104
100
foo .assert_not_awaited ()
105
101
106
102
107
- @pytest .mark .skipif (IS_WASM , reason = "Can't test async code in WASM" )
108
103
def test_sync_mixin (sync_loop ) -> None :
109
104
class AsyncFoo :
110
105
def __init__ (self ) -> None :
0 commit comments