Skip to content

Commit fe11e12

Browse files
committed
some fixes
1 parent ae4a43e commit fe11e12

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

tests/conftest.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,22 @@ def pytest_configure(config: pytest.Config) -> None:
120120
"markers",
121121
"min_bin_version(version): skip test if Tarantool binary version is below the specified version",
122122
)
123+
config.addinivalue_line(
124+
"markers",
125+
"max_bin_version(version): skip test if Tarantool binary version is above the specified version",
126+
)
123127

124128

125129
def pytest_collection_modifyitems(
126130
config: pytest.Config, items: list[pytest.Item]
127131
) -> None:
128-
"""Skip tests based on min_bin_version marker."""
132+
"""Skip tests based on min_bin_version and max_bin_version markers."""
129133
bin_version = get_tarantool_bin_version()
130134
if bin_version is None:
131135
return
132136

133137
for item in items:
138+
# Check min_bin_version marker
134139
marker = item.get_closest_marker("min_bin_version")
135140
if marker is not None:
136141
min_version = marker.args[0]
@@ -141,6 +146,17 @@ def pytest_collection_modifyitems(
141146
)
142147
)
143148

149+
# Check max_bin_version marker
150+
marker = item.get_closest_marker("max_bin_version")
151+
if marker is not None:
152+
max_version = marker.args[0]
153+
if bin_version >= max_version:
154+
item.add_marker(
155+
pytest.mark.skip(
156+
reason=f"Requires Tarantool < {max_version}, got {bin_version}"
157+
)
158+
)
159+
144160

145161
# --- Tarantool Instance Fixtures ---
146162

tests/test_connect.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ async def test_connect_waiting_for_spaces_no_reconnect(
586586
finally:
587587
await conn.disconnect()
588588

589+
@pytest.mark.max_bin_version((1, 7))
589590
async def test_connect_waiting_for_spaces_no_reconnect_1_6(
590591
self, tnt: TarantoolSyncInstance, in_docker: bool
591592
) -> None:
@@ -596,13 +597,6 @@ async def test_connect_waiting_for_spaces_no_reconnect_1_6(
596597
instance.start(wait=False)
597598
await asyncio.sleep(1)
598599

599-
# Check if version < 1.7
600-
async with asynctnt.Connection(
601-
host=instance.host, port=instance.port, fetch_schema=False
602-
) as check_conn:
603-
if check_conn.version >= (1, 7):
604-
pytest.skip("Test only for Tarantool < 1.7")
605-
606600
conn = asynctnt.Connection(
607601
host=instance.host,
608602
port=instance.port,
@@ -644,6 +638,7 @@ async def test_connect_err_loading(
644638
finally:
645639
await conn.disconnect()
646640

641+
@pytest.mark.max_bin_version((1, 7))
647642
async def test_connect_err_loading_1_6(
648643
self, tnt: TarantoolSyncInstance, in_docker: bool
649644
) -> None:
@@ -654,13 +649,6 @@ async def test_connect_err_loading_1_6(
654649
instance.start(wait=False)
655650
await asyncio.sleep(1)
656651

657-
# Check if version < 1.7
658-
async with asynctnt.Connection(
659-
host=instance.host, port=instance.port, fetch_schema=False
660-
) as check_conn:
661-
if check_conn.version >= (1, 7):
662-
pytest.skip("Test only for Tarantool < 1.7")
663-
664652
conn = asynctnt.Connection(
665653
host=instance.host,
666654
port=instance.port,
@@ -745,11 +733,9 @@ async def state_checker() -> None:
745733
await conn.disconnect()
746734

747735
@pytest.mark.min_bin_version((2, 10))
748-
async def test_features(self, tnt: TarantoolSyncInstance) -> None:
736+
@pytest.mark.max_bin_version((3, 0))
737+
async def test_features_before_3_0(self, tnt: TarantoolSyncInstance) -> None:
749738
async with asynctnt.Connection(host=tnt.host, port=tnt.port) as conn:
750-
if conn.version >= (3, 0):
751-
pytest.skip(f"Requires Tarantool < (3, 0), got {conn.version}")
752-
753739
assert conn.features is not None
754740
assert conn.features.streams
755741
assert conn.features.watchers
@@ -764,7 +750,7 @@ async def test_features(self, tnt: TarantoolSyncInstance) -> None:
764750
assert not conn.features.call_arg_tuple_extension
765751

766752
@pytest.mark.min_bin_version((3, 0))
767-
async def test_features_3_0(self, tnt: TarantoolSyncInstance) -> None:
753+
async def test_features(self, tnt: TarantoolSyncInstance) -> None:
768754
async with asynctnt.Connection(host=tnt.host, port=tnt.port) as conn:
769755
assert conn.features is not None
770756
assert conn.features.streams

0 commit comments

Comments
 (0)