From 3982d5057334bb6cd911d06d362f0184f44ef443 Mon Sep 17 00:00:00 2001 From: STJ Date: Mon, 16 Mar 2026 19:47:31 -0700 Subject: [PATCH] Lean up implementation --- tests/integration/console.py | 8 ------- tests/integration/helpers.py | 26 ++--------------------- tests/integration/test_browser_actions.py | 15 ++++--------- 3 files changed, 6 insertions(+), 43 deletions(-) diff --git a/tests/integration/console.py b/tests/integration/console.py index 950c5c77..10284843 100644 --- a/tests/integration/console.py +++ b/tests/integration/console.py @@ -111,7 +111,6 @@ def record_failure( label, reason, result=None, - screenshot_path=None, ): _failures.append( { @@ -119,7 +118,6 @@ def record_failure( "label": label, "reason": reason, "result": result, - "screenshot": screenshot_path, } ) @@ -138,7 +136,6 @@ def _print_summary(): name = f.get("name", "?") reason = str(f.get("reason", f.get("details", ""))) result = f.get("result") - screenshot = f.get("screenshot") _console.print(f" [bold red]── {name} ──[/]") @@ -150,16 +147,11 @@ def _print_summary(): _console.print(" [red]│[/]") _console.print(" [red]╰─▶[/] [dim]result:[/]") for k, v in result.items(): - if k == "screenshot": - continue v_str = str(v) if len(v_str) > 120: v_str = v_str[:120] + "…" _console.print(f" [dim]{k}:[/] {rich_escape(v_str)}") - if screenshot: - _console.print(f" [dim]screenshot:[/] [underline]{rich_escape(screenshot)}[/]") - _console.print() total = _passed + _failed diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index 559426c0..4459622d 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -1,22 +1,10 @@ -import base64 import inspect -import shutil -from pathlib import Path from pytest_check import check from . import console as ui -SCREENSHOTS_DIR = Path(__file__).parent / "screenshots" - - -def setup_screenshots_dir(): - if SCREENSHOTS_DIR.exists(): - shutil.rmtree(SCREENSHOTS_DIR) - SCREENSHOTS_DIR.mkdir(exist_ok=True) - - class Browser: def __init__(self, agent_id, agent_state=None): self._agent_id = agent_id @@ -43,7 +31,8 @@ class Browser: result = future.result(timeout=120) if "error" in result: Fail(result).error(result["error"]) - _strip_screenshot(result, _caller_test_name()) + if "screenshot" in result: + result["screenshot"] = "[Image]" return result return call @@ -68,20 +57,10 @@ def _caller_test_name(): return "unknown" -def _strip_screenshot(result, name): - b64 = result.pop("screenshot", None) - if not b64 or not isinstance(b64, str) or len(b64) < 100: - return - path = SCREENSHOTS_DIR / f"{name}.png" - path.write_bytes(base64.b64decode(b64)) - result["screenshot_path"] = str(path) - - class Fail: def __init__(self, result=None): self._result = result self._name = _caller_test_name() - self._screenshot = result.get("screenshot_path") if result else None def expected(self, value): self._expected = value @@ -100,7 +79,6 @@ class Fail: self._name, reason, self._result, - self._screenshot, ) with check: check.fail(f"[{self._name}] {reason}") diff --git a/tests/integration/test_browser_actions.py b/tests/integration/test_browser_actions.py index cc0fb604..00c8ccdb 100644 --- a/tests/integration/test_browser_actions.py +++ b/tests/integration/test_browser_actions.py @@ -1,15 +1,11 @@ -from pathlib import Path - import pytest from . import console as ui -from .helpers import Fail, setup_screenshots_dir +from .helpers import Fail pytestmark = pytest.mark.integration -setup_screenshots_dir() - def test_navigate(browser): ui.status("test_navigate → example.com") @@ -88,13 +84,10 @@ def test_screenshot(browser): browser.navigate(url="https://example.com") result = browser.screenshot() - path = result.get("screenshot_path") - ui.log(f"screenshot → {path}") + ui.log(f"screenshot → {result.get('screenshot')}") - if not path: - Fail(result).error("no screenshot saved") - elif not Path(path).exists(): - Fail(result).error(f"screenshot file missing: {path}") + if result.get("screenshot") != "[Image]": + Fail(result).error("expected screenshot in response") def test_input(browser):