File tree 2 files changed +28
-9
lines changed
tests/unit/providers/coroutines
2 files changed +28
-9
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from __future__ import absolute_import
4
4
5
+ import asyncio
5
6
import copy
6
7
import errno
7
8
import functools
@@ -27,17 +28,19 @@ except ImportError:
27
28
import __builtin__ as builtins
28
29
29
30
try :
30
- import asyncio
31
+ from inspect import _is_coroutine_mark as _is_coroutine_marker
31
32
except ImportError :
32
- asyncio = None
33
- _is_coroutine_marker = None
34
- else :
35
- if sys.version_info >= (3 , 5 , 3 ):
36
- import asyncio.coroutines
37
- _is_coroutine_marker = asyncio.coroutines._is_coroutine
38
- else :
33
+ try :
34
+ # Python >=3.12.0,<3.12.5
35
+ from inspect import _is_coroutine_marker
36
+ except ImportError :
39
37
_is_coroutine_marker = True
40
38
39
+ try :
40
+ from asyncio.coroutines import _is_coroutine
41
+ except ImportError :
42
+ _is_coroutine = True
43
+
41
44
try :
42
45
import ConfigParser as iniconfigparser
43
46
except ImportError :
@@ -1475,7 +1478,8 @@ cdef class Coroutine(Callable):
1475
1478
some_coroutine. add_kwargs( keyword_argument1=3, keyword_argument=4)
1476
1479
"""
1477
1480
1478
- _is_coroutine = _is_coroutine_marker
1481
+ _is_coroutine_marker = _is_coroutine_marker # Python >=3.12
1482
+ _is_coroutine = _is_coroutine # Python <3.16
1479
1483
1480
1484
def set_provides (self , provides ):
1481
1485
""" Set provider provides."""
Original file line number Diff line number Diff line change 1
1
"""Coroutine provider tests."""
2
+ import sys
2
3
3
4
from dependency_injector import providers , errors
4
5
from pytest import mark , raises
@@ -208,3 +209,17 @@ def test_repr():
208
209
"<dependency_injector.providers."
209
210
"Coroutine({0}) at {1}>" .format (repr (example ), hex (id (provider )))
210
211
)
212
+
213
+
214
+ @mark .skipif (sys .version_info > (3 , 15 ), reason = "requires Python<3.16" )
215
+ def test_asyncio_iscoroutinefunction () -> None :
216
+ from asyncio .coroutines import iscoroutinefunction
217
+
218
+ assert iscoroutinefunction (providers .Coroutine (example ))
219
+
220
+
221
+ @mark .skipif (sys .version_info < (3 , 12 ), reason = "requires Python>=3.12" )
222
+ def test_inspect_iscoroutinefunction () -> None :
223
+ from inspect import iscoroutinefunction
224
+
225
+ assert iscoroutinefunction (providers .Coroutine (example ))
You can’t perform that action at this time.
0 commit comments