Skip to content

Commit a365d26

Browse files
committed
fix unused import
1 parent 0415f60 commit a365d26

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
"""Override report_context to disable log file simulation for integration tests in this directory so that we can exercise the context manager when no log file is provided."""
22

3+
from sift_client.util.test_results.pytest_util import (
4+
report_context_no_logging as report_context, # noqa: F401
5+
)

python/lib/sift_client/resources/sync_stubs/__init__.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,15 +2001,16 @@ class TestResultsAPI:
20012001
"""
20022002
...
20032003

2004-
def import_log_file(self, log_file: str | Path) -> ReplayResult:
2004+
def import_log_file(self, log_file: str | Path, incremental: bool = False) -> ReplayResult:
20052005
"""Replay a log file by parsing each entry, simulating the results, then creating for real.
20062006
20072007
This method reads a log file created by the simulation logging, reconstructs
20082008
all the objects via simulation, and then creates them via the actual API.
20092009
IDs are mapped from simulated to real during the creation process.
20102010
20112011
Args:
2012-
log_file: Path to the log file to replay.
2012+
log_file: Path to the log file to import.
2013+
incremental: (internal tooling) If True, goes line by line and calls every event vs. reading the entire file at once and sending resultant test report.
20132014
20142015
Returns:
20152016
A ReplayResult containing the created report, steps, and measurements.

python/lib/sift_client/resources/test_results.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ async def delete_measurement(self, *, test_measurement: str | TestMeasurement) -
619619
async def import_log_file(
620620
self,
621621
log_file: str | Path,
622+
incremental: bool = False,
622623
) -> ReplayResult:
623624
"""Replay a log file by parsing each entry, simulating the results, then creating for real.
624625
@@ -627,12 +628,13 @@ async def import_log_file(
627628
IDs are mapped from simulated to real during the creation process.
628629
629630
Args:
630-
log_file: Path to the log file to replay.
631+
log_file: Path to the log file to import.
632+
incremental: (internal tooling) If True, goes line by line and calls every event vs. reading the entire file at once and sending resultant test report.
631633
632634
Returns:
633635
A ReplayResult containing the created report, steps, and measurements.
634636
"""
635-
result = await self._low_level_client.import_log_file(log_file)
637+
result = await self._low_level_client.import_log_file(log_file, incremental=incremental)
636638
result.report = self._apply_client_to_instance(result.report)
637639
result.steps = self._apply_client_to_instances(result.steps)
638640
result.measurements = self._apply_client_to_instances(result.measurements)

python/lib/sift_client/scripts/import_test_result_log.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
import select
99
import sys
1010
import tempfile
11+
from typing import TYPE_CHECKING
1112

1213
from sift_client import SiftClient, SiftConnectionConfig
1314

15+
if TYPE_CHECKING:
16+
from sift_client._internal.low_level_wrappers.test_results import ReplayResult
17+
1418
logger = logging.getLogger(__name__)
1519

1620

17-
def _print_result(result) -> None:
21+
def _print_result(result: ReplayResult) -> None:
1822
print(f"Report: {result.report.name} (id={result.report.id_})")
1923
print(f"Steps: {len(result.steps)}")
2024
for step in result.steps:
@@ -24,7 +28,7 @@ def _print_result(result) -> None:
2428
print(f" - {m.name}: passed={m.passed}")
2529

2630

27-
def _incremental_import_loop(client, log_file) -> None:
31+
def _incremental_import_loop(client: SiftClient, log_file: str) -> ReplayResult | None:
2832
"""Replay incrementally in a loop until stdin is closed (EOF)."""
2933
result = None
3034
while True:
@@ -85,7 +89,8 @@ def main() -> None:
8589
)
8690
raise
8791

88-
_print_result(result)
92+
if result:
93+
_print_result(result)
8994

9095

9196
if __name__ == "__main__":

0 commit comments

Comments
 (0)