2020-06-20 14:53:44 +02:00
|
|
|
import pytest
|
2020-02-08 13:39:35 +01:00
|
|
|
|
|
|
|
import util.cli
|
|
|
|
|
2020-06-20 15:11:53 +02:00
|
|
|
|
2020-06-20 14:53:44 +02:00
|
|
|
def test_valid_command():
|
|
|
|
assert util.cli.execute("echo test") == "test\n"
|
2020-05-03 11:15:52 +02:00
|
|
|
|
2020-06-20 15:11:53 +02:00
|
|
|
|
2020-06-20 14:53:44 +02:00
|
|
|
def test_utf_command():
|
|
|
|
rv = util.cli.execute("echo ÖPmŧß")
|
|
|
|
assert util.cli.execute("echo ÖPmŧß") == "ÖPmŧß\n"
|
|
|
|
|
2020-06-20 15:11:53 +02:00
|
|
|
|
2020-06-20 14:53:44 +02:00
|
|
|
def test_invalid_command():
|
|
|
|
with pytest.raises(RuntimeError):
|
|
|
|
util.cli.execute("i-do-not-exist")
|
|
|
|
|
2020-06-20 15:11:53 +02:00
|
|
|
|
2020-06-20 14:53:44 +02:00
|
|
|
def test_command_exit_code():
|
|
|
|
with pytest.raises(RuntimeError):
|
|
|
|
util.cli.execute("cat i-do-not-exist")
|
|
|
|
|
2020-06-20 15:11:53 +02:00
|
|
|
|
2020-06-20 14:53:44 +02:00
|
|
|
def test_command_exit_code_no_error():
|
|
|
|
util.cli.execute("cat i-do-not-exist", ignore_errors=True)
|
|
|
|
|
2020-06-20 15:11:53 +02:00
|
|
|
|
2020-06-20 14:53:44 +02:00
|
|
|
def test_async():
|
|
|
|
assert util.cli.execute("echo test", wait=False) == ""
|
2020-05-03 11:15:52 +02:00
|
|
|
|
2020-02-08 13:39:35 +01:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|