DetachHead / pytest-robotframework

a pytest plugin that creates robotframework reports for tests written in python and allows you to run robotframework tests with pytest

Home Page:https://detachhead.github.io/pytest-robotframework/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Capture robot warnings and insert them into pytest

KotlinIsland opened this issue · comments

Must consider robot warnings and user warnings (logger.warn/Log level=WARN)

# testing/test_asdf.py
from __future__ import annotations

import warnings


def test_it1():
    warnings.warn("I'm warning")
# testing/test.robot
*** Settings ***
Library     testing.util


*** Test Cases ***
Bar
    Log    I'm robot warning    level=warn
> pytest -p robotframework testing
================================================================================== test session starts ===================================================================================
platform win32 -- Python 3.12.2, pytest-8.2.1, pluggy-1.5.0 -- C:\Users\amongus\projects\pytest-robotframework\.venv\Scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\amongus\projects\pytest-robotframework
configfile: pyproject.toml
plugins: pytest_robotframework-4.1.4, github-actions-annotate-failures-0.2.0, xdist-3.6.1
collected 2 items
[ WARN ] Imported library 'testing.util' contains no keywords.

testing/test.robot::Bar PASSED                                                                                                                                                      [ 50%] 
testing/test_asdf.py::test_it1 PASSED                                                                                                                                               [100%] 

==================================================================================== warnings summary ==================================================================================== 
testing/test_asdf.py::test_it1
  c:\Users\amongus\projects\pytest-robotframework\testing\test_asdf.py:7: UserWarning: I'm warning
    warnings.warn("I'm warning")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Robot Framework Output Files:
Log:     C:\Users\amongus\projects\pytest-robotframework\log.html
Log URI: file:///C:/Users/amongus/projects/pytest-robotframework/log.html
============================================================================== 2 passed, 1 warning in 0.24s ============================================================================== 
[ WARN ] I'm robot warning