Best Python code snippet using playwright-python
faulthandler.py
Source:faulthandler.py
...13 import faulthandler14 # avoid trying to dup sys.stderr if faulthandler is already enabled15 if faulthandler.is_enabled():16 return17 stderr_fd_copy = os.dup(_get_stderr_fileno())18 config.fault_handler_stderr = os.fdopen(stderr_fd_copy, "w")19 faulthandler.enable(file=config.fault_handler_stderr)20def _get_stderr_fileno():21 try:22 return sys.stderr.fileno()23 except (AttributeError, io.UnsupportedOperation):24 # python-xdist monkeypatches sys.stderr with an object that is not an actual file.25 # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors26 # This is potentially dangerous, but the best we can do.27 return sys.__stderr__.fileno()28def pytest_unconfigure(config):29 import faulthandler30 faulthandler.disable()31 # close our dup file installed during pytest_configure32 f = getattr(config, "fault_handler_stderr", None)33 if f is not None:34 # re-enable the faulthandler, attaching it to the default sys.stderr35 # so we can see crashes after pytest has finished, usually during36 # garbage collection during interpreter shutdown37 config.fault_handler_stderr.close()38 del config.fault_handler_stderr39 faulthandler.enable(file=_get_stderr_fileno())40@pytest.hookimpl(hookwrapper=True)41def pytest_runtest_protocol(item):42 timeout = float(item.config.getini("faulthandler_timeout") or 0.0)43 if timeout > 0:44 import faulthandler45 stderr = item.config.fault_handler_stderr46 faulthandler.dump_traceback_later(timeout, file=stderr)47 try:48 yield49 finally:50 faulthandler.cancel_dump_traceback_later()51 else:52 yield53@pytest.hookimpl(tryfirst=True)...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!