Skip to content

Commit 67afc3b

Browse files
committed
clean up
1 parent 214d986 commit 67afc3b

10 files changed

Lines changed: 291 additions & 699 deletions

File tree

python/docs/examples/pytest_plugin.md

Lines changed: 110 additions & 165 deletions
Large diffs are not rendered by default.

python/lib/sift_client/_tests/conftest.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,17 @@ def ci_pytest_tag(sift_client):
7979

8080

8181
def pytest_configure(config: pytest.Config) -> None:
82-
"""Enable the Sift connection-check mode for the fixtures used in this test suite since we run w/ mock client in non-integration tests."""
83-
config.option.sift_test_results_check_connection = True
82+
"""Pick a plugin mode based on whether integration tests are being run.
83+
84+
Integration runs targeting a real backend stay online with the log file
85+
disabled (writes go inline). Otherwise force offline mode so the autouse
86+
plugin fixtures construct cleanly without contacting Sift.
87+
"""
88+
is_integration_run = "integration" in (config.option.markexpr or "")
89+
have_real_backend = all(
90+
os.getenv(name) for name in ("SIFT_API_KEY", "SIFT_GRPC_URI", "SIFT_REST_URI")
91+
)
92+
if is_integration_run and have_real_backend:
93+
config.option.sift_log_file = "none"
94+
else:
95+
config.option.sift_offline = True
Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
"""Shared helpers for the pytest-plugin test suite.
22
33
The tests in this directory drive inner pytester sessions to exercise the
4-
plugin's behavior in isolation. The fixtures below produce the boilerplate
5-
conftests those inner sessions need:
6-
7-
- ``write_plugin_conftest``: minimal conftest that loads the plugin
8-
- ``write_probe_conftest``: conftest that loads the plugin and runs a probe
9-
block inside ``pytest_configure``, useful for inspecting internal state
10-
without running tests against a real backend
4+
plugin's behavior in isolation.
115
"""
126

137
from __future__ import annotations
148

15-
import textwrap
169
from typing import Callable
1710

1811
import pytest
1912

20-
pytest_plugins = ["pytester"]
21-
2213

2314
@pytest.fixture
2415
def write_plugin_conftest(pytester: pytest.Pytester) -> Callable[[], None]:
@@ -28,21 +19,3 @@ def _write() -> None:
2819
pytester.makeconftest('pytest_plugins = ["sift_client.pytest_plugin"]')
2920

3021
return _write
31-
32-
33-
@pytest.fixture
34-
def write_probe_conftest(pytester: pytest.Pytester) -> Callable[[str], None]:
35-
"""Return a callable that writes a conftest running ``probe_body`` in ``pytest_configure``.
36-
37-
``probe_body`` is python source that runs at config time with ``config``
38-
in scope; use ``print(...)`` calls and capture them with
39-
``result.stdout.fnmatch_lines``.
40-
"""
41-
42-
def _write(probe_body: str) -> None:
43-
pytester.makeconftest(
44-
'pytest_plugins = ["sift_client.pytest_plugin"]\n\n'
45-
"def pytest_configure(config):\n" + textwrap.indent(textwrap.dedent(probe_body), " ")
46-
)
47-
48-
return _write

python/lib/sift_client/_tests/pytest_plugin/test_configuration.py

Lines changed: 0 additions & 154 deletions
This file was deleted.

python/lib/sift_client/_tests/pytest_plugin/test_credentials.py

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import pytest
2-
3-
4-
def pytest_configure(config: pytest.Config) -> None:
5-
"""Configure the pytest configuration to disable the Sift test results log file."""
6-
config.option.sift_test_results_log_file = False
1+
# Plugin mode (offline vs online, log-file disable) is set by the parent
2+
# conftest based on the marker expression and env vars. No util-specific
3+
# overrides are needed.

0 commit comments

Comments
 (0)