@@ -50,7 +50,6 @@ async def test_sqlite_only(db):
5050 "TortoiseContext" ,
5151 "tortoise_test_context" ,
5252 "requireCapability" ,
53- "skipCapability" ,
5453 "truncate_all_models" ,
5554 "init_memory_sqlite" ,
5655 "SkipTest" ,
@@ -236,69 +235,6 @@ def skip_wrapper(*args: typing.Any, **kwargs: typing.Any) -> typing.Any:
236235 return decorator
237236
238237
239- def skipCapability (
240- connection_name : str = "models" , ** conditions : typing .Any
241- ) -> Callable [[_FT ], _FT ]:
242- """
243- Skip a test if the specified capabilities are matched.
244-
245- This is the inverse of :func:`requireCapability`.
246-
247- Usage:
248-
249- .. code-block:: python3
250-
251- @skipCapability(dialect='postgres')
252- @pytest.mark.asyncio
253- async def test_skip_on_postgres(db):
254- ...
255-
256- :param connection_name: name of the connection to retrieve capabilities from.
257- :param conditions: capability tests — if all match, the test is skipped.
258- """
259-
260- def decorator (test_item : _FT ) -> _FT :
261- if not isinstance (test_item , type ):
262-
263- def check_capabilities () -> None :
264- db = get_connection (connection_name )
265- if all (getattr (db .capabilities , key ) == val for key , val in conditions .items ()):
266- raise SkipTest (f"Skipped because capabilities match: { conditions } " )
267-
268- if inspect .iscoroutinefunction (test_item ):
269-
270- @wraps (test_item )
271- async def skip_wrapper (* args : typing .Any , ** kwargs : typing .Any ) -> typing .Any :
272- check_capabilities ()
273- return await test_item (* args , ** kwargs )
274-
275- else :
276-
277- @wraps (test_item )
278- def skip_wrapper (* args : typing .Any , ** kwargs : typing .Any ) -> typing .Any :
279- check_capabilities ()
280- return test_item (* args , ** kwargs )
281-
282- return cast (_FT , skip_wrapper )
283-
284- # Assume a class is decorated
285- funcs = {
286- var : f
287- for var in dir (test_item )
288- if var .startswith ("test_" ) and callable (f := getattr (test_item , var ))
289- }
290- for name , func in funcs .items ():
291- setattr (
292- test_item ,
293- name ,
294- skipCapability (connection_name = connection_name , ** conditions )(func ),
295- )
296-
297- return test_item
298-
299- return decorator
300-
301-
302238@typing .overload
303239def init_memory_sqlite (models : ModulesConfigType | None = None ) -> AsyncFuncDeco : ...
304240
0 commit comments