Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions snowflake_sql_api/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,14 +599,16 @@ def make_client(
from .client import SnowflakeClient

_reject_managed_kwargs("make_client", kwargs)
return SnowflakeClient(
client = SnowflakeClient(
account,
user,
private_key=_throwaway_key(),
http_client=httpx.Client(transport=fake.transport),
poll_interval=poll_interval,
**kwargs,
)
client._transport._owns_client = True
return client


def make_async_client(
Expand All @@ -621,14 +623,16 @@ def make_async_client(
from .aclient import AsyncSnowflakeClient

_reject_managed_kwargs("make_async_client", kwargs)
return AsyncSnowflakeClient(
client = AsyncSnowflakeClient(
account,
user,
private_key=_throwaway_key(),
http_client=httpx.AsyncClient(transport=fake.transport),
poll_interval=poll_interval,
**kwargs,
)
client._transport._owns_client = True
return client


# ---------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
PASSPHRASE = b"correct horse battery staple"


def pytest_configure(config: pytest.Config) -> None:
"""Load shipped testing fixtures when pytest11 entry points are unavailable."""
if not config.pluginmanager.hasplugin("snowflake_sql_api"):
config.pluginmanager.import_plugin("snowflake_sql_api.testing")


@pytest.fixture
def fake_account() -> str:
"""A region-suffixed account locator for auth-normalization tests."""
Expand Down
2 changes: 2 additions & 0 deletions tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_make_client_returns_real_client() -> None:
assert isinstance(client, SnowflakeClient)
assert client.query_scalar("SELECT 1") == 1
client.close()
assert client._transport._client.is_closed


def test_make_client_rejects_managed_kwargs() -> None:
Expand Down Expand Up @@ -304,6 +305,7 @@ async def test_async_query() -> None:
assert isinstance(client, AsyncSnowflakeClient)
assert await client.query("SELECT id FROM t") == [{"ID": 1}, {"ID": 2}]
await client.aclose()
assert client._transport._client.is_closed


async def test_async_submit_and_result() -> None:
Expand Down