Skip to content

PexpectLibrary initialization fails: Union cannot be empty #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
csanchezdll opened this issue Jun 9, 2025 · 0 comments
Open

PexpectLibrary initialization fails: Union cannot be empty #351

csanchezdll opened this issue Jun 9, 2025 · 0 comments

Comments

@csanchezdll
Copy link

Using PexpectLibrary (https://github.com/lipan-sudo/PexpectLibrary) in RF 7.3 yields an error during initialization and some of the keywords fail to be registered:

docker run -ti ubuntu:22.04
[...]
# apt install pip
[...]
# pip install robotframework==7.3
[...]
# pip install PexpectLibrary==0.2.0
[...]
# cat test.robot
root@14df3f2e8fa5:/test# cat test.robot 
*** Settings ***

Library    PexpectLibrary

*** Test Cases ***

Test
    ${proc}    Spawn    cat

# robot .
==============================================================================
Test                                                                          
==============================================================================
[ ERROR ] Error in library 'PexpectLibrary': Adding keyword 'popen_spawn' failed: Union cannot be empty.
[ ERROR ] Error in library 'PexpectLibrary': Adding keyword 'spawn' failed: Union cannot be empty.
Test.Test                                                                     
==============================================================================
Test                                                                  | FAIL |
No keyword with name 'Spawn' found. Did you mean:
    PexpectLibrary.Spawnu
    PexpectLibrary.Fd Spawn
------------------------------------------------------------------------------
Test.Test                                                             | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Test                                                                  | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  /test/output.xml
Log:     /test/log.html
Report:  /test/report.html

Related past problem: https://forum.robotframework.org/t/error-in-faker-library/6743

I have debugged this to the keyword argument validation logic detecting a problem on preexec_fn: Optional[Callable[[], Any]] = None, (https://github.com/lipan-sudo/PexpectLibrary/blob/384794dc4b917d08963cfb95d7a6a135b4f8dfec/PexpectLibrary/__init__.py#L118C15-L118C62). Removing the type hints make the keywords register successfully, but AFAIU the hints are valid and the problem is on how RF fails validation there.

Note that RF 7.2.2 did not exhibit this problem:

# pip install robotframework==7.2.2
[...]
# robot .
==============================================================================
Test                                                                          
==============================================================================
Test.Test                                                                     
==============================================================================
Test                                                                  | PASS |
------------------------------------------------------------------------------
Test.Test                                                             | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Test                                                                  | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output:  /test/output.xml
Log:     /test/log.html
Report:  /test/report.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant