File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
tests/unit/providers/coroutines Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -26,17 +26,22 @@ except ImportError:
2626 # Python 2.7
2727 import __builtin__ as builtins
2828
29+ try :
30+ from inspect import _is_coroutine_marker
31+ except ImportError :
32+ _is_coroutine_marker = True
33+
2934try :
3035 import asyncio
3136except ImportError :
3237 asyncio = None
33- _is_coroutine_marker = None
38+ _is_coroutine = None
3439else :
3540 if sys.version_info >= (3 , 5 , 3 ):
3641 import asyncio.coroutines
37- _is_coroutine_marker = asyncio.coroutines._is_coroutine
42+ _is_coroutine = asyncio.coroutines._is_coroutine
3843 else :
39- _is_coroutine_marker = True
44+ _is_coroutine = True
4045
4146try :
4247 import ConfigParser as iniconfigparser
@@ -1434,7 +1439,8 @@ cdef class Coroutine(Callable):
14341439 some_coroutine. add_kwargs( keyword_argument1=3, keyword_argument=4)
14351440 """
14361441
1437- _is_coroutine = _is_coroutine_marker
1442+ _is_coroutine_marker = _is_coroutine_marker # Python >=3.12
1443+ _is_coroutine = _is_coroutine # Python <3.16
14381444
14391445 def set_provides (self , provides ):
14401446 """ Set provider provides."""
Original file line number Diff line number Diff line change 11"""Coroutine provider tests."""
2+ import sys
23
34from dependency_injector import providers , errors
45from pytest import mark , raises
@@ -208,3 +209,17 @@ def test_repr():
208209 "<dependency_injector.providers."
209210 "Coroutine({0}) at {1}>" .format (repr (example ), hex (id (provider )))
210211 )
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