Skip to content

Commit 77ca02e

Browse files
author
Andrei Neagu
committed
enhanced helpers
1 parent 751a3b1 commit 77ca02e

File tree

1 file changed

+7
-4
lines changed
  • services/dynamic-scheduler/tests/unit/api_frontend

1 file changed

+7
-4
lines changed

services/dynamic-scheduler/tests/unit/api_frontend/helpers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
SCREENSHOT_SUFFIX = ".ignore.screenshot.png"
2323

2424

25+
async def take_screenshot(async_page: Page, prefix: str = "") -> None:
26+
path = SCREENSHOTS_PATH / f"{prefix}{uuid4()}{SCREENSHOT_SUFFIX}"
27+
await async_page.screenshot(path=path)
28+
print(f"Please check :{path}")
29+
30+
2531
@asynccontextmanager
2632
async def take_screenshot_on_error(
2733
async_page: Page,
@@ -30,10 +36,7 @@ async def take_screenshot_on_error(
3036
yield
3137
# allows to also capture exceptions form `with pytest.raise(...)``
3238
except BaseException:
33-
path = SCREENSHOTS_PATH / f"{uuid4()}{SCREENSHOT_SUFFIX}"
34-
await async_page.screenshot(path=path)
35-
print(f"Please check :{path}")
36-
39+
await take_screenshot(async_page)
3740
raise
3841

3942

0 commit comments

Comments
 (0)