Skip to content

Commit ff2a8ea

Browse files
committed
refactor: remove deprecated save_error_snapshot_legacy function and its tests, exposing save_error_snapshot_enhanced in its place.
1 parent da987d5 commit ff2a8ea

3 files changed

Lines changed: 2 additions & 53 deletions

File tree

browser_utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
capture_playwright_state,
66
get_texas_timestamp,
77
save_comprehensive_snapshot,
8-
save_error_snapshot_legacy,
8+
save_error_snapshot_enhanced,
99
)
1010
from .initialization import (
1111
_close_page_logic,
@@ -63,7 +63,7 @@
6363
"PageController",
6464
# Debug utilities (comprehensive error snapshots)
6565
"save_comprehensive_snapshot",
66-
"save_error_snapshot_legacy",
66+
"save_error_snapshot_enhanced",
6767
"get_texas_timestamp",
6868
"capture_dom_structure",
6969
"capture_playwright_state",

browser_utils/debug_utils.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -694,20 +694,3 @@ async def save_error_snapshot_enhanced(
694694
locators=locators,
695695
error_exception=error_exception,
696696
)
697-
698-
699-
async def save_error_snapshot_legacy(error_name: str = "error") -> None:
700-
"""
701-
Legacy error snapshot function for backward compatibility.
702-
703-
DEPRECATED: Use save_error_snapshot_enhanced() or save_comprehensive_snapshot() instead.
704-
705-
Args:
706-
error_name: Error name with optional req_id suffix (e.g., "error_hbfu521")
707-
"""
708-
# Delegate to enhanced function with minimal context
709-
await save_error_snapshot_enhanced(
710-
error_name=error_name,
711-
error_stage="Legacy snapshot call",
712-
additional_context={"legacy_call": True},
713-
)

tests/browser_utils/test_debug_utils.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
get_texas_timestamp,
2525
save_comprehensive_snapshot,
2626
save_error_snapshot_enhanced,
27-
save_error_snapshot_legacy,
2827
)
2928

3029
# === Smart Fixtures to Reduce Mocking ===
@@ -715,36 +714,3 @@ async def test_enhanced_snapshot_with_exception(
715714
# Verify exception was passed
716715
call_kwargs = mock_save.call_args[1]
717716
assert call_kwargs["error_exception"] == error_exc
718-
719-
720-
# === Section 7: Legacy Snapshot Tests ===
721-
722-
723-
class TestSaveErrorSnapshotLegacy:
724-
"""测试遗留错误快照函数"""
725-
726-
@pytest.mark.asyncio
727-
async def test_legacy_snapshot_delegates_to_enhanced(self):
728-
"""测试遗留函数委托给增强函数"""
729-
with patch(
730-
"browser_utils.debug_utils.save_error_snapshot_enhanced"
731-
) as mock_enhanced:
732-
await save_error_snapshot_legacy(error_name="legacy_error_req9999")
733-
734-
# Verify enhanced was called
735-
mock_enhanced.assert_called_once()
736-
call_kwargs = mock_enhanced.call_args[1]
737-
assert call_kwargs["error_name"] == "legacy_error_req9999"
738-
assert call_kwargs["error_stage"] == "Legacy snapshot call"
739-
assert call_kwargs["additional_context"]["legacy_call"] is True
740-
741-
@pytest.mark.asyncio
742-
async def test_legacy_snapshot_default_error_name(self):
743-
"""测试默认错误名称"""
744-
with patch(
745-
"browser_utils.debug_utils.save_error_snapshot_enhanced"
746-
) as mock_enhanced:
747-
await save_error_snapshot_legacy()
748-
749-
call_kwargs = mock_enhanced.call_args[1]
750-
assert call_kwargs["error_name"] == "error"

0 commit comments

Comments
 (0)