pytest-dev/pytest-testinfra

Allow disabling argument quoting with `run` function for WinRM backends

Open

#310 geöffnet am 4. Mai 2018

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Python (318 Forks)batch import
help wantedwindows

Repository-Metriken

Stars
 (2.156 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 87T 19h) (6 gemergte PRs in 30 T)

Beschreibung

Hello,

Consider the following basic WinRM test:

def test_echo(host):
    hello = 'Hello, world!'
    res = host.run('echo %s', hello)
    assert res.stdout == hello # Fails
    assert res.stdout== hello
E   assert '"Hello, world!"\r\n' == 'Hello, world!'
# I'm fine with that extra CRLF, but the quotes bugged me for some time...

Related log entry: INFO:testinfra:RUN CommandResult(command='echo "Hello, world!"', exit_status=0, stdout=b'"Hello, world!"\r\n', stderr=None)

It would be nice to be able to turn off argument quoting for executables which behave like MS echo (they echo back quotes, apparently :panda_face: ). Pywinrm already seems to handle arguments escaping/quoting, but I haven't played much with this library yet. It could be possible to let pywinrm handle the command formatting/escaping.

Unrelated to this issue, worth mentioning: the CommandResult.stdout value is a binary string instead of a string when using run with WinRM. Is it intended?

Contributor Guide