DetachHead / pytest-robotframework

a pytest plugin that creates robotframework reports for tests written in python and allows you to run robotframework tests with pytest
https://detachhead.github.io/pytest-robotframework/
MIT License
23 stars 1 forks source link

Failure when `robot.api.logger.console` #55

Open KotlinIsland opened 10 months ago

KotlinIsland commented 10 months ago
from robot.api import logger
def test_among():
    logger.console("I am console")

It actually does work: image

pytest test.py                                                                                                                                                                                                                                                                                                                                                                                     19:34:36  
=============================================================================================================================================================================================================================== test session starts ===============================================================================================================================================================================================================================
platform win32 -- Python 3.11.3, pytest-7.4.0, pluggy-1.3.0
rootdir: C:\Users\AMONGUS\projects\python-test
plugins: robotframework-1.4.0
collected 1 item                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
==============================================================================
Python-Test
==============================================================================
Python-Test.Test                                                              
==============================================================================
test_among
test.py .FI am console
test_among                                                            | FAIL |                                                                                                                                                                                                                                                                                                                                                                                        [100%]        
OSError: [WinError 6] The handle is invalid
------------------------------------------------------------------------------
Python-Test.Test                                                      | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Python-Test                                                           | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  C:\Users\AMONGUS\projects\python-test\output.xml
Log:     C:\Users\AMONGUS\projects\python-test\log.html
Report:  C:\Users\AMONGUS\projects\python-test\report.html

==================================================================================================================================================================================================================================== FAILURES ===================================================================================================================================================================================================================================== 
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________ test_among ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________ 

    def test_among():
>       logger.console("I am console")

test.py:3:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
..\..\AppData\Local\pypoetry\Cache\virtualenvs\demo-B_iquuwg-py3.11\Lib\site-packages\robot\api\logger.py:144: in console
    librarylogger.console(msg, newline, stream)
..\..\AppData\Local\pypoetry\Cache\virtualenvs\demo-B_iquuwg-py3.11\Lib\site-packages\robot\output\librarylogger.py:70: in console
    write_to_console(msg, newline, stream)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

msg = 'I am console\n', newline = True, stream = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>

    def write_to_console(msg, newline=True, stream='stdout'):
        msg = str(msg)
        if newline:
            msg += '\n'
        stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__
>       stream.write(console_encode(msg, stream=stream))
E       OSError: [WinError 6] The handle is invalid

..\..\AppData\Local\pypoetry\Cache\virtualenvs\demo-B_iquuwg-py3.11\Lib\site-packages\robot\output\loggerhelper.py:40: OSError
============================================================================================================================================================================================================================= short test summary info ============================================================================================================================================================================================================================= 
FAILED test.py::test_among - OSError: [WinError 6] The handle is invalid
================================================================================================================================================================================================================================ 1 failed in 0.19s ================================================================================================================================================================================================================================ 
KotlinIsland commented 2 months ago

obsolete

DetachHead commented 2 months ago

this issue seems to be fixed now

DetachHead commented 2 months ago

actually its not

KotlinIsland commented 2 months ago

Maybe capture=no should be default or something?