style: apply ruff format across the codebase
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
5ec5ad615a
commit
68978a34e7
+16
-7
@@ -158,11 +158,17 @@ class TestResourceCleanup:
|
||||
|
||||
stopped = []
|
||||
monkeypatch.setattr(wabot, "stop_service", lambda pid: stopped.append(pid))
|
||||
store.save(wabot.SessionRecord(
|
||||
name="s1", executor_url="http://127.0.0.1:7777", session_id="old",
|
||||
browser="chromium", created_at=datetime.now(timezone.utc).isoformat(),
|
||||
service_pid=9999, service_port=7777,
|
||||
))
|
||||
store.save(
|
||||
wabot.SessionRecord(
|
||||
name="s1",
|
||||
executor_url="http://127.0.0.1:7777",
|
||||
session_id="old",
|
||||
browser="chromium",
|
||||
created_at=datetime.now(timezone.utc).isoformat(),
|
||||
service_pid=9999,
|
||||
service_port=7777,
|
||||
)
|
||||
)
|
||||
fake_selenium.service_alive.return_value = True
|
||||
fake_selenium.attach.return_value = None # session dead on a live server
|
||||
wabot.browser(session="s1", store=store)
|
||||
@@ -176,8 +182,11 @@ class TestDestroyEdges:
|
||||
from datetime import datetime, timezone
|
||||
|
||||
defaults = dict(
|
||||
name="s1", executor_url="http://127.0.0.1:7777", session_id="old",
|
||||
browser="chromium", created_at=datetime.now(timezone.utc).isoformat(),
|
||||
name="s1",
|
||||
executor_url="http://127.0.0.1:7777",
|
||||
session_id="old",
|
||||
browser="chromium",
|
||||
created_at=datetime.now(timezone.utc).isoformat(),
|
||||
)
|
||||
defaults.update(kw)
|
||||
store.save(wabot.SessionRecord(**defaults))
|
||||
|
||||
@@ -97,7 +97,7 @@ class TestPerform:
|
||||
bot.set_page(Login)
|
||||
bot.perform("explode")
|
||||
assert bot.perform("do_login") is None # refused
|
||||
assert bot.do_login() is None # __getattr__ path also refused
|
||||
assert bot.do_login() is None # __getattr__ path also refused
|
||||
bot.reset()
|
||||
assert bot.perform("do_login") == "logged-in"
|
||||
|
||||
|
||||
@@ -73,9 +73,7 @@ class TestGetProxy:
|
||||
browser = make_browser()
|
||||
page = BasePage(browser)
|
||||
result = page["rows"]
|
||||
browser.driver.find_elements.assert_called_once_with(
|
||||
by="css selector", value="tr.row"
|
||||
)
|
||||
browser.driver.find_elements.assert_called_once_with(by="css selector", value="tr.row")
|
||||
assert result is browser.driver.find_elements.return_value
|
||||
|
||||
def test_unknown_key_returns_falsy_nullfield(self):
|
||||
|
||||
@@ -16,9 +16,7 @@ class TestReattachingRemote:
|
||||
assert isinstance(driver.caps, dict)
|
||||
|
||||
def test_works_for_firefox_options_too(self):
|
||||
driver = ReattachingRemote(
|
||||
"http://127.0.0.1:1", "sid", options=build_options("firefox")
|
||||
)
|
||||
driver = ReattachingRemote("http://127.0.0.1:1", "sid", options=build_options("firefox"))
|
||||
assert driver.session_id == "sid"
|
||||
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@ class TestChromiumPath:
|
||||
assert Image.open(out).size == (100, 150)
|
||||
# scrolled at least twice beyond the initial position
|
||||
scroll_calls = [
|
||||
c for c in driver.execute_script.call_args_list
|
||||
c
|
||||
for c in driver.execute_script.call_args_list
|
||||
if c.args and str(c.args[0]).startswith("window.scrollTo")
|
||||
]
|
||||
assert len(scroll_calls) >= 2
|
||||
@@ -77,17 +78,17 @@ class TestChromiumPath:
|
||||
"return window.innerHeight": 60,
|
||||
}.get(script) # window.scrollTo(...) -> None
|
||||
driver.get_screenshot_as_png.side_effect = [
|
||||
png_bytes(100, 60, (255, 0, 0)), # tile @ y=0
|
||||
png_bytes(100, 60, (0, 255, 0)), # tile @ y=60
|
||||
png_bytes(100, 60, (0, 0, 255)), # tile @ y=120, clamped to paste_y=90
|
||||
png_bytes(100, 60, (255, 0, 0)), # tile @ y=0
|
||||
png_bytes(100, 60, (0, 255, 0)), # tile @ y=60
|
||||
png_bytes(100, 60, (0, 0, 255)), # tile @ y=120, clamped to paste_y=90
|
||||
]
|
||||
out = tmp_path / "shot.png"
|
||||
assert save_full_page(driver, str(out)) is True
|
||||
img = Image.open(out)
|
||||
assert img.size == (100, 150)
|
||||
assert img.getpixel((50, 30)) == (255, 0, 0) # first tile
|
||||
assert img.getpixel((50, 75)) == (0, 255, 0) # second tile (rows 60-89)
|
||||
assert img.getpixel((50, 140)) == (0, 0, 255) # third tile, bottom-aligned
|
||||
assert img.getpixel((50, 30)) == (255, 0, 0) # first tile
|
||||
assert img.getpixel((50, 75)) == (0, 255, 0) # second tile (rows 60-89)
|
||||
assert img.getpixel((50, 140)) == (0, 0, 255) # third tile, bottom-aligned
|
||||
|
||||
def test_wide_page_clamps_last_column(self, tmp_path):
|
||||
driver = MagicMock(name="driver")
|
||||
@@ -99,12 +100,12 @@ class TestChromiumPath:
|
||||
"return window.innerHeight": 60,
|
||||
}.get(script)
|
||||
driver.get_screenshot_as_png.side_effect = [
|
||||
png_bytes(100, 60, (255, 0, 0)), # column @ x=0
|
||||
png_bytes(100, 60, (0, 0, 255)), # column @ x=100, clamped to paste_x=50
|
||||
png_bytes(100, 60, (255, 0, 0)), # column @ x=0
|
||||
png_bytes(100, 60, (0, 0, 255)), # column @ x=100, clamped to paste_x=50
|
||||
]
|
||||
out = tmp_path / "shot.png"
|
||||
assert save_full_page(driver, str(out)) is True
|
||||
img = Image.open(out)
|
||||
assert img.size == (150, 60)
|
||||
assert img.getpixel((25, 30)) == (255, 0, 0) # left column (cols 0-49)
|
||||
assert img.getpixel((140, 30)) == (0, 0, 255) # right column, clamped (cols 50-149)
|
||||
assert img.getpixel((25, 30)) == (255, 0, 0) # left column (cols 0-49)
|
||||
assert img.getpixel((140, 30)) == (0, 0, 255) # right column, clamped (cols 50-149)
|
||||
|
||||
Reference in New Issue
Block a user