Skip to content

Commit 1f93afc

Browse files
fix: pytests now pass with pytest-asyncio v0.19.0 (#189)
* Added pytest_asyncio to fixture decorators for connection and cursor defs in conftest to pass unit tests using pytest-asyncio>=0.19.0. * Started adding pytest_asyncio to fixture decorators in integration tests. * Added pytest_asyncio to fixtures in integration async conftest modules. Some integration tests still aren't passing. * Changed pytest.fixture and pytest_asyncio.fixture imports to be more consistent. * Pinned pytest-asyncio version to 0.19.0. * Had missed a few pytest_asyncio.fixture -> asyncfixture imports.
1 parent fdd1a1f commit 1f93afc

File tree

7 files changed

+64
-62
lines changed

7 files changed

+64
-62
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dev =
4949
pre-commit==2.15.0
5050
pyfakefs>=4.5.3
5151
pytest==6.2.5
52-
pytest-asyncio<0.19.0
52+
pytest-asyncio==0.19.0
5353
pytest-cov==3.0.0
5454
pytest-httpx==0.21.0
5555
pytest-mock==3.6.1

tests/integration/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from os import environ
33

44
from pytest import fixture
5+
from pytest_asyncio import fixture as async_fixture
56

67
from firebolt.service.manager import Settings
78

@@ -24,7 +25,7 @@ def must_env(var_name: str) -> str:
2425
return environ[var_name]
2526

2627

27-
@fixture(scope="session")
28+
@async_fixture(scope="session")
2829
def rm_settings(api_endpoint, username, password) -> Settings:
2930
return Settings(
3031
server=api_endpoint,

tests/integration/dbapi/async/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pytest import fixture
1+
from pytest_asyncio import fixture as async_fixture
22

33
from firebolt.async_db import Connection, connect
44

55

6-
@fixture
6+
@async_fixture
77
async def connection(
88
engine_url: str,
99
database_name: str,
@@ -23,7 +23,7 @@ async def connection(
2323
yield connection
2424

2525

26-
@fixture
26+
@async_fixture
2727
async def connection_engine_name(
2828
engine_name: str,
2929
database_name: str,
@@ -44,7 +44,7 @@ async def connection_engine_name(
4444
yield connection
4545

4646

47-
@fixture
47+
@async_fixture
4848
async def connection_no_engine(
4949
database_name: str,
5050
username: str,

tests/integration/dbapi/sync/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pytest import fixture
1+
from pytest_asyncio import fixture as async_fixture
22

33
from firebolt.db import Connection, connect
44

55

6-
@fixture
6+
@async_fixture
77
def connection(
88
engine_url: str,
99
database_name: str,
@@ -24,7 +24,7 @@ def connection(
2424
connection.close()
2525

2626

27-
@fixture
27+
@async_fixture
2828
def connection_engine_name(
2929
engine_name: str,
3030
database_name: str,
@@ -45,7 +45,7 @@ def connection_engine_name(
4545
connection.close()
4646

4747

48-
@fixture
48+
@async_fixture
4949
def connection_no_engine(
5050
database_name: str,
5151
username: str,

tests/unit/async_db/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Dict
33

44
from pytest import fixture
5+
from pytest_asyncio import fixture as asyncio_fixture
56

67
from firebolt.async_db import (
78
ARRAY,
@@ -15,7 +16,7 @@
1516
from tests.unit.db_conftest import * # noqa
1617

1718

18-
@fixture
19+
@asyncio_fixture
1920
async def connection(settings: Settings, db_name: str) -> Connection:
2021
async with (
2122
await connect(
@@ -30,7 +31,7 @@ async def connection(settings: Settings, db_name: str) -> Connection:
3031
yield connection
3132

3233

33-
@fixture
34+
@asyncio_fixture
3435
async def cursor(connection: Connection, settings: Settings) -> Cursor:
3536
return connection.cursor()
3637

tests/unit/client/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22
import typing
33

44
import httpx
5-
import pytest
65
from httpx import Response
6+
from pytest import fixture
77

88
from firebolt.common.settings import Settings
99

1010

11-
@pytest.fixture
11+
@fixture
1212
def test_token(access_token: str) -> str:
1313
return access_token
1414

1515

16-
@pytest.fixture
16+
@fixture
1717
def test_token2() -> str:
1818
return "test_token2"
1919

2020

21-
@pytest.fixture
21+
@fixture
2222
def test_username(settings: Settings) -> str:
2323
return settings.user
2424

2525

26-
@pytest.fixture
26+
@fixture
2727
def test_password(settings: Settings) -> str:
2828
return settings.password.get_secret_value()
2929

3030

31-
@pytest.fixture
31+
@fixture
3232
def check_credentials_callback(
3333
test_username: str, test_password: str, test_token: str
3434
) -> typing.Callable:

0 commit comments

Comments
 (0)