File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 55import sys
66import warnings
77
8+ import inspect
9+
810
911def import_deprecated (name ):
1012 """Import *name* while suppressing DeprecationWarning."""
@@ -49,12 +51,20 @@ def ignore_warnings(*, category):
4951 more noisy and tools like 'git blame' less useful.
5052 """
5153 def decorator (test ):
52- @functools .wraps (test )
53- def wrapper (self , * args , ** kwargs ):
54- with warnings .catch_warnings ():
55- warnings .simplefilter ('ignore' , category = category )
56- return test (self , * args , ** kwargs )
57- return wrapper
54+ if inspect .iscoroutinefunction (test ):
55+ @functools .wraps (test )
56+ async def async_wrapper (self , * args , ** kwargs ):
57+ with warnings .catch_warnings ():
58+ warnings .simplefilter ('ignore' , category = category )
59+ return await test (self , * args , ** kwargs )
60+ return async_wrapper
61+ else :
62+ @functools .wraps (test )
63+ def wrapper (self , * args , ** kwargs ):
64+ with warnings .catch_warnings ():
65+ warnings .simplefilter ('ignore' , category = category )
66+ return test (self , * args , ** kwargs )
67+ return wrapper
5868 return decorator
5969
6070
You can’t perform that action at this time.
0 commit comments