Skip to content

Commit 1501928

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 d656a0b commit 1501928

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

test/topology/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ def pytest_addoption(parser):
4646
help='Connect to CQL via an encrypted TLSv1.2 connection')
4747

4848

49+
@pytest.fixture(scope="session")
50+
def event_loop(request):
51+
loop = asyncio.get_event_loop_policy().new_event_loop()
52+
yield loop
53+
loop.close()
54+
55+
4956
# "cql" fixture: set up client object for communicating with the CQL API.
5057
# The host/port combination of the server are determined by the --host and
5158
# --port options, and defaults to localhost and 9042, respectively.

test/topology/test_null.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from pylib.util import random_string, unique_name
2020
import pytest
2121

22-
@pytest.fixture(scope="module")
22+
23+
@pytest.fixture(scope="session")
2324
def table1(cql, test_keyspace):
2425
table = test_keyspace + "." + unique_name()
2526
cql.execute(f"CREATE TABLE {table} (p text, c text, v text, primary key (p, c))")

0 commit comments

Comments
 (0)