Skip to content

Commit db54554

Browse files
author
Alejo Sanchez
committed
test.py topology: session scope for common fixtures
Change default pytest-asyncio event_loop fixture scope to session to allow async fixtures with scope larger than function. See pytest-dev/pytest-asyncio#68 Change temporarily table1 fixture to session scope. Signed-off-by: Alejo Sanchez <[email protected]>
1 parent f918ece commit db54554

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

test/topology/conftest.py

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ def pytest_addoption(parser):
3030
help='Connect to CQL via an encrypted TLSv1.2 connection')
3131

3232

33+
@pytest.fixture(scope="session")
34+
def event_loop(request):
35+
loop = asyncio.get_event_loop_policy().new_event_loop()
36+
yield loop
37+
loop.close()
38+
39+
3340
# "cql" fixture: set up client object for communicating with the CQL API.
3441
# The host/port combination of the server are determined by the --host and
3542
# --port options, and defaults to localhost and 9042, respectively.

test/topology/test_null.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from pylib.util import random_string, unique_name
88
import pytest
99

10-
@pytest.fixture(scope="module")
10+
11+
@pytest.fixture(scope="session")
1112
def table1(cql, test_keyspace):
1213
table = test_keyspace + "." + unique_name()
1314
cql.execute(f"CREATE TABLE {table} (p text, c text, v text, primary key (p, c))")

0 commit comments

Comments
 (0)