Skip to content

Commit d4463db

Browse files
igorcodingclaude
andcommitted
Restore min_bin_version marker functionality
Add pytest hooks to register and handle the min_bin_version marker: - pytest_configure: registers the marker - pytest_collection_modifyitems: skips tests based on Tarantool binary version - get_tarantool_bin_version: caches the version from a temporary instance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f3700d9 commit d4463db

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

tests/conftest.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
TESTER_SPACE_ID = 512
2020
TESTER_SPACE_NAME = "tester"
2121

22-
2322
# --- Event Loop Configuration ---
2423

2524

@@ -93,6 +92,56 @@ def create_tarantool_instance(
9392
)
9493

9594

95+
# --- Binary Version Checking ---
96+
97+
# Global to cache the Tarantool binary version
98+
_tarantool_bin_version: tuple[int, ...] | None = None
99+
100+
101+
def get_tarantool_bin_version() -> tuple[int, ...] | None:
102+
"""Get the Tarantool binary version, starting a temporary instance if needed."""
103+
global _tarantool_bin_version
104+
if _tarantool_bin_version is not None:
105+
return _tarantool_bin_version
106+
107+
instance = create_tarantool_instance()
108+
try:
109+
instance.start()
110+
_tarantool_bin_version = instance.bin_version
111+
finally:
112+
instance.stop()
113+
114+
return _tarantool_bin_version
115+
116+
117+
def pytest_configure(config: pytest.Config) -> None:
118+
"""Register custom markers."""
119+
config.addinivalue_line(
120+
"markers",
121+
"min_bin_version(version): skip test if Tarantool binary version is below the specified version",
122+
)
123+
124+
125+
def pytest_collection_modifyitems(
126+
config: pytest.Config, items: list[pytest.Item]
127+
) -> None:
128+
"""Skip tests based on min_bin_version marker."""
129+
bin_version = get_tarantool_bin_version()
130+
if bin_version is None:
131+
return
132+
133+
for item in items:
134+
marker = item.get_closest_marker("min_bin_version")
135+
if marker is not None:
136+
min_version = marker.args[0]
137+
if bin_version < min_version:
138+
item.add_marker(
139+
pytest.mark.skip(
140+
reason=f"Requires Tarantool >= {min_version}, got {bin_version}"
141+
)
142+
)
143+
144+
96145
# --- Tarantool Instance Fixtures ---
97146

98147

0 commit comments

Comments
 (0)