Skip to content

Commit a335a0f

Browse files
committed
IGNITE-27373 Improve tests
1 parent 102c2b8 commit a335a0f

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

modules/platforms/python/dbapi/tests/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,26 @@
2525

2626
TEST_PAGE_SIZE = 32
2727

28+
TEST_CONNECT_KWARGS = {
29+
"address": server_addresses_basic,
30+
"page_size": TEST_PAGE_SIZE,
31+
"heartbeat_interval": 2,
32+
}
33+
2834
@pytest.fixture()
2935
def table_name(request):
3036
return f"{request.node.originalname}_{int(time.monotonic_ns())}"
3137

3238

3339
@pytest.fixture()
3440
def connection():
35-
conn = pyignite_dbapi.connect(address=server_addresses_basic, page_size=TEST_PAGE_SIZE, heartbeat_interval=2)
41+
conn = pyignite_dbapi.connect(**TEST_CONNECT_KWARGS)
3642
yield conn
3743
conn.close()
3844

3945
@pytest.fixture()
4046
def service_connection():
41-
conn = pyignite_dbapi.connect(address=server_addresses_basic, page_size=TEST_PAGE_SIZE, heartbeat_interval=2)
47+
conn = pyignite_dbapi.connect(**TEST_CONNECT_KWARGS)
4248
yield conn
4349
conn.close()
4450

modules/platforms/python/dbapi/tests/test_concurrency.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
import pytest
2020

2121
import pyignite_dbapi
22-
from tests.util import server_addresses_basic
22+
from tests.conftest import TEST_CONNECT_KWARGS
2323

2424

25-
CONNECT_KWARGS = {"address": server_addresses_basic}
2625
NUM_THREADS = 50
2726

2827

@@ -77,7 +76,7 @@ def task(_):
7776

7877
def test_concurrent_connect_use_close(module_level_threadsafety):
7978
def task(_):
80-
c = pyignite_dbapi.connect(**CONNECT_KWARGS)
79+
c = pyignite_dbapi.connect(**TEST_CONNECT_KWARGS)
8180
with c.cursor() as cur:
8281
cur.execute("SELECT 1")
8382
assert cur.fetchone() is not None
@@ -118,7 +117,7 @@ def test_concurrent_commit_and_rollback(table, module_level_threadsafety):
118117
lock = threading.Lock()
119118

120119
def task(thread_id):
121-
with pyignite_dbapi.connect(**CONNECT_KWARGS) as conn:
120+
with pyignite_dbapi.connect(**TEST_CONNECT_KWARGS) as conn:
122121
conn.autocommit = False
123122
with conn.cursor() as cur:
124123
cur.execute(f"INSERT INTO {table} (id, data) VALUES (?, ?)", (thread_id, "x"))
@@ -133,7 +132,7 @@ def task(thread_id):
133132

134133
time.sleep(3.0)
135134

136-
with pyignite_dbapi.connect(**CONNECT_KWARGS) as conn:
135+
with pyignite_dbapi.connect(**TEST_CONNECT_KWARGS) as conn:
137136
with conn.cursor() as cur:
138137
cur.execute(f"SELECT id FROM {table} ORDER BY id")
139138
found_ids = {row[0] for row in cur.fetchall()}

0 commit comments

Comments
 (0)