Skip to content

Commit ae4a43e

Browse files
igorcodingclaude
andcommitted
Extract check_version function from ensure_version decorator
Separates version-checking logic into a reusable check_version function that can be called directly in tests, while ensure_version decorator now delegates to it for cleaner code organization. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d4463db commit ae4a43e

1 file changed

Lines changed: 43 additions & 19 deletions

File tree

tests/conftest.py

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,42 @@ async def fill_data_dict(conn: asynctnt.Connection) -> list[dict]:
244244
# --- Version Checking ---
245245

246246

247+
def check_version(
248+
version: tuple[int, ...],
249+
*,
250+
min: tuple[int, ...] | None = None,
251+
max: tuple[int, ...] | None = None,
252+
min_included: bool = True,
253+
max_included: bool = False,
254+
) -> None:
255+
"""
256+
Check if version meets requirements, skip test if not.
257+
258+
Args:
259+
version: The version tuple to check
260+
min: Minimum required version tuple (e.g., (2, 10))
261+
max: Maximum required version tuple (e.g., (3, 0))
262+
min_included: Whether min version is inclusive (default True)
263+
max_included: Whether max version is inclusive (default False)
264+
265+
Raises:
266+
pytest.skip: If version requirements aren't met
267+
"""
268+
# Check minimum version
269+
if min is not None:
270+
if min_included and version < min:
271+
pytest.skip(f"Requires Tarantool >= {min}, got {version}")
272+
if not min_included and version <= min:
273+
pytest.skip(f"Requires Tarantool > {min}, got {version}")
274+
275+
# Check maximum version
276+
if max is not None:
277+
if max_included and version > max:
278+
pytest.skip(f"Requires Tarantool <= {max}, got {version}")
279+
if not max_included and version >= max:
280+
pytest.skip(f"Requires Tarantool < {max}, got {version}")
281+
282+
247283
def ensure_version(
248284
*,
249285
min: tuple[int, ...] | None = None,
@@ -297,25 +333,13 @@ async def wrapper(*args, **kwargs):
297333
f"Could not find connection parameter '{conn}' in test function"
298334
)
299335

300-
version = connection.version
301-
302-
# Check minimum version
303-
if min is not None:
304-
if min_included and version < min:
305-
pytest.skip(f"Requires Tarantool >= {min}, got {version}")
306-
return
307-
if not min_included and version <= min:
308-
pytest.skip(f"Requires Tarantool > {min}, got {version}")
309-
return
310-
311-
# Check maximum version
312-
if max is not None:
313-
if max_included and version > max:
314-
pytest.skip(f"Requires Tarantool <= {max}, got {version}")
315-
return
316-
if not max_included and version >= max:
317-
pytest.skip(f"Requires Tarantool < {max}, got {version}")
318-
return
336+
check_version(
337+
connection.version,
338+
min=min,
339+
max=max,
340+
min_included=min_included,
341+
max_included=max_included,
342+
)
319343

320344
return await func(*args, **kwargs)
321345

0 commit comments

Comments
 (0)