Skip to content

Commit 0b7bb86

Browse files
committed
Removed the skipCapability function.
1 parent fa341d0 commit 0b7bb86

2 files changed

Lines changed: 2 additions & 65 deletions

File tree

tests/test_distinct.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from tests.testmodels import Tournament
44
from tortoise.contrib import test
5+
from tortoise.contrib.test.condition import NotIn
56
from tortoise.exceptions import OperationalError
67

78
# ---------------------------------------------------------------------------
@@ -197,7 +198,7 @@ async def test_distinct_on_invalid_order_by(db):
197198
await Tournament.all().distinct("name").order_by("desc")
198199

199200

200-
@test.skipCapability(dialect="postgres")
201+
@test.requireCapability(dialect=NotIn("postgres"))
201202
@pytest.mark.asyncio
202203
async def test_distinct_on_not_supported_outside_postgres(db):
203204
with pytest.raises(OperationalError):

tortoise/contrib/test/__init__.py

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -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
303239
def init_memory_sqlite(models: ModulesConfigType | None = None) -> AsyncFuncDeco: ...
304240

0 commit comments

Comments
 (0)