#11 Fix several issues around quoting, background processes, and encoding
Closed by pviktori. Opened by pviktori.
pviktori/python-pytest-multihost encodings-background  into  master

Download 11.patch

I've spent a day on python-pytest-multihost, fixing several issues that piled up in the meanwhile. They're all subtly connected.

  • Set a policy regarding bytes, text, strings and encodings when dealing with file contents -- see the change in README.rst. Update Host and Transport to match.

  • Currently, when stdin was given to a command, no EOF was sent. We assumed the program would only read as much stdout as it needed. This is an issue, especially with background tasks. To fix this, stdin is now piped to the command through echo.
    Also, stdin_text passed to commands is now binary-safe, if given as a bytestring.

  • Command (i.e. what host.run_command returns) is now a context manager, which is useful for background tasks:

    with host.run_command(['cat', pipe_filename], bg=True) as cat:
        host.run_command('cat > ' + pipe_filename, stdin_text='foo')
    
  • Clarify that wait() should be called for all background tasks (either explicitly, or by with with).

  • Remove the buggy test test_background, instead add tests for the above.

  • Add a Tox configuration file.

Fixes: https://pagure.io/python-pytest-multihost/issue/6
Fixes: https://pagure.io/python-pytest-multihost/issue/7
Fixes: https://pagure.io/python-pytest-multihost/pull-request/9

Hello! You need also change the wait method of a command class as for now it does not use the raiseonerr you've set on the line 96.

1 new commit added

  • Honor instance attribute if raiseonerr is not passed to Command.wait()

Thanks for noticing; that should be fixed now.

reviewed out-of-band by aslaikov

Pull-Request has been closed by pviktori

Metadata