Skip to content

Commit 696807a

Browse files
committed
Replace print with logger.* in DisplayFixture
1 parent e9f6d33 commit 696807a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/reactpy/testing/display.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
from contextlib import AsyncExitStack
5+
from logging import getLogger
56
from types import TracebackType
67
from typing import TYPE_CHECKING, Any
78

@@ -14,6 +15,8 @@
1415
if TYPE_CHECKING:
1516
import pytest
1617

18+
_logger = getLogger(__name__)
19+
1720

1821
class DisplayFixture:
1922
"""A fixture for running web-based tests using ``playwright``"""
@@ -77,12 +80,16 @@ async def configure_page(self) -> None:
7780
self.page.set_default_timeout(self.timeout * 1000)
7881
self.page.on(
7982
"requestfailed",
80-
lambda x: print(f"BROWSER LOAD ERROR: {x.url}\n{x.failure}"), # noqa: T201
83+
lambda x: _logger.error(f"BROWSER LOAD ERROR: {x.url}\n{x.failure}"),
84+
)
85+
self.page.on(
86+
"console", lambda x: _logger.info(f"BROWSER CONSOLE: {x.text}")
8187
)
82-
self.page.on("console", lambda x: print(f"BROWSER CONSOLE: {x.text}")) # noqa: T201
8388
self.page.on(
8489
"pageerror",
85-
lambda x: print(f"BROWSER ERROR: {x.name} - {x.message}\n{x.stack}"), # noqa: T201
90+
lambda x: _logger.error(
91+
f"BROWSER ERROR: {x.name} - {x.message}\n{x.stack}"
92+
),
8693
)
8794

8895
async def __aexit__(

0 commit comments

Comments
 (0)