Skip to content

Commit 5eaa0c7

Browse files
igorcodingclaude
andcommitted
Rewrite test suite from unittest to pytest
- Replace unittest.TestCase with pytest-style test classes - Add conftest.py with fixtures for Tarantool instances and connections - Convert ensure_version from inline function to decorator - Add min_bin_version marker for binary version checks at collection time - Move assertions to tests/utils/assertions.py - Remove _testbase.py (replaced by conftest.py fixtures) - Update all test files to use pytest fixtures and decorators Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d9a4f68 commit 5eaa0c7

24 files changed

+2641
-2788
lines changed

asynctnt/instance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ def __init__(
768768
wal_mode="none",
769769
initlua_template=None,
770770
applua="-- app.lua --",
771+
extra_box_cfg="",
771772
timeout=10.0,
772773
):
773774
super().__init__(
@@ -786,6 +787,7 @@ def __init__(
786787
cleanup=True,
787788
initlua_template=initlua_template,
788789
applua=applua,
790+
extra_box_cfg=extra_box_cfg,
789791
timeout=timeout,
790792
)
791793
self._docker_image = docker_image or "tarantool/tarantool"

pyproject.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ classifiers=[
2828
requires-python = '>=3.9.0'
2929
readme = "README.md"
3030
dependencies = [
31-
'PyYAML >= 5.0',
31+
"ruff>=0.14.13",
3232
]
3333

3434
[project.urls]
@@ -38,7 +38,8 @@ github = "https://github.com/igorcoding/asynctnt"
3838
test = [
3939
'ruff',
4040
'uvloop>=0.12.3; platform_system != "Windows" and platform.python_implementation != "PyPy"',
41-
'pytest',
41+
'pytest>=8.0.0',
42+
'pytest-asyncio>=0.24.0',
4243
'pytest-cov',
4344
'coverage[toml]',
4445
'pytz',
@@ -72,9 +73,16 @@ include = ["asynctnt", "asynctnt.*"]
7273
"*" = ["*.c", "*.h"]
7374

7475
[tool.pytest.ini_options]
75-
addopts = "--strict --tb native"
76+
addopts = "--strict-markers --tb native"
7677
testpaths = "tests"
7778
filterwarnings = "default"
79+
asyncio_mode = "auto"
80+
asyncio_default_fixture_loop_scope = "function"
81+
markers = [
82+
"min_version(version): skip if Tarantool version < specified",
83+
"max_version(version): skip if Tarantool version >= specified",
84+
"min_bin_version(version): skip based on binary version",
85+
]
7886

7987
[tool.coverage.run]
8088
branch = true

tests/__init__.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1 @@
1-
import logging
2-
import os
3-
import sys
4-
import unittest
5-
6-
from ._testbase import TarantoolTestCase
7-
8-
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
9-
10-
11-
class BaseTarantoolTestCase(TarantoolTestCase):
12-
DO_CONNECT = True
13-
LOGGING_LEVEL = getattr(logging, os.getenv("LOG", "CRITICAL").upper())
14-
LOGGING_STREAM = sys.stdout
15-
TNT_APP_LUA_PATH = os.path.join(CURRENT_DIR, "files", "app.lua")
16-
17-
TESTER_SPACE_ID = 512
18-
TESTER_SPACE_NAME = "tester"
19-
20-
async def truncate(self):
21-
if self.conn and self.conn.is_connected:
22-
await self.conn.call("truncate", timeout=5)
23-
24-
def tearDown(self):
25-
if hasattr(self, "conn"):
26-
self.loop.run_until_complete(self.truncate())
27-
super().tearDown()
28-
29-
30-
def suite():
31-
loader = unittest.TestLoader()
32-
return loader.discover(CURRENT_DIR, pattern="test_*.py")
33-
34-
35-
if __name__ == "__main__":
36-
runner = unittest.TextTestRunner(verbosity=2)
37-
result = runner.run(suite())
38-
sys.exit(not result.wasSuccessful())
1+
"""Asynctnt test suite."""

0 commit comments

Comments
 (0)