Skip to content

Commit 766e2a7

Browse files
committed
fix: repair test_batch_cli and clean up lint warnings
- Add missing total_detections param to format_summary test calls - Update assertions to match current output format - Remove unused imports in test_patch.py and test_patch_cli.py - Apply ruff format to 3 files
1 parent 2f72d59 commit 766e2a7

5 files changed

Lines changed: 38 additions & 24 deletions

File tree

tests/test_batch_cli.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,31 @@ def test_format_summary():
9797
from uitag.batch_cli import format_summary
9898

9999
summary = format_summary(
100-
succeeded=4, failed=1, total_seconds=9.5, output_dir="output/"
100+
succeeded=4,
101+
failed=1,
102+
total_detections=42,
103+
total_seconds=9.5,
104+
output_dir="output/",
101105
)
102-
assert "4 succeeded" in summary
106+
assert "42 detections" in summary
103107
assert "1 failed" in summary
104108
assert "9.5s" in summary
109+
assert "4 images" in summary
105110

106111

107112
def test_format_summary_no_failures():
108113
"""Summary omits failure count when all succeed."""
109114
from uitag.batch_cli import format_summary
110115

111116
summary = format_summary(
112-
succeeded=3, failed=0, total_seconds=5.2, output_dir="out/"
117+
succeeded=3,
118+
failed=0,
119+
total_detections=30,
120+
total_seconds=5.2,
121+
output_dir="out/",
113122
)
114-
assert "3 succeeded" in summary
123+
assert "30 detections" in summary
124+
assert "3 images" in summary
115125
assert "failed" not in summary
116126

117127

tests/test_patch.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""Tests for patch JSON application."""
22

3-
import json
43
import pytest
5-
from PIL import Image
64

75
from uitag.types import Detection
86

tests/test_patch_cli.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Tests for patch and render CLI subcommands."""
22

33
import json
4-
import pytest
54
from PIL import Image
65

76
from uitag.types import Detection
@@ -88,15 +87,17 @@ def test_patch_cli_produces_output(tmp_path):
8887
patch_path = _write_patch(tmp_path, [{"som_id": 1, "label": "new"}])
8988

9089
out_dir = tmp_path / "out"
91-
patch_main([
92-
str(img_path),
93-
"--manifest",
94-
str(manifest_path),
95-
"--patch",
96-
str(patch_path),
97-
"-o",
98-
str(out_dir),
99-
])
90+
patch_main(
91+
[
92+
str(img_path),
93+
"--manifest",
94+
str(manifest_path),
95+
"--patch",
96+
str(patch_path),
97+
"-o",
98+
str(out_dir),
99+
]
100+
)
100101

101102
assert (out_dir / "test-uitag.png").exists()
102103
assert (out_dir / "test-uitag-manifest.json").exists()
@@ -114,12 +115,14 @@ def test_render_cli_produces_output(tmp_path):
114115
manifest_path = _write_manifest(tmp_path, dets, 200, 200)
115116

116117
out_dir = tmp_path / "out"
117-
render_main([
118-
str(img_path),
119-
"--manifest",
120-
str(manifest_path),
121-
"-o",
122-
str(out_dir),
123-
])
118+
render_main(
119+
[
120+
str(img_path),
121+
"--manifest",
122+
str(manifest_path),
123+
"-o",
124+
str(out_dir),
125+
]
126+
)
124127

125128
assert (out_dir / "test-uitag.png").exists()

tests/test_rescan.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def test_run_pipeline_accepts_rescan_params():
109109
from uitag.run import run_pipeline
110110

111111
import inspect
112+
112113
sig = inspect.signature(run_pipeline)
113114
assert "rescan" in sig.parameters
114115
assert "rescan_threshold" in sig.parameters

uitag/batch_cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ def batch_main(argv: list[str] | None = None) -> None:
135135

136136
# Warm the backend import before starting timer
137137
info = backend.info()
138-
source_label = args.path[0].rstrip("/") if len(args.path) == 1 else f"{len(args.path)} paths"
138+
source_label = (
139+
args.path[0].rstrip("/") if len(args.path) == 1 else f"{len(args.path)} paths"
140+
)
139141
print(f"Running pipeline on: {len(image_paths)} images in {source_label}/")
140142
print(f"Backend: {info.name} ({info.device}) | OCR mode: {ocr_mode}\n")
141143

0 commit comments

Comments
 (0)