From 9d6e85e931950a4b89729bf27c60a6dd90aa05ba Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 1 May 2022 17:18:48 +0200 Subject: [PATCH] Added SysCommand() tests --- tests/syscalls/test_syscommand.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/syscalls/test_syscommand.py diff --git a/tests/syscalls/test_syscommand.py b/tests/syscalls/test_syscommand.py new file mode 100644 index 00000000..122f196e --- /dev/null +++ b/tests/syscalls/test_syscommand.py @@ -0,0 +1,18 @@ +import pytest + +def test_SysCommand(): + import archinstall + import subprocess + + if not archinstall.SysCommand('whoami').decode().strip() == subprocess.check_output('whoami').decode().strip(): + raise AssertionError(f"SysCommand('whoami') did not return expected output: {subprocess.check_output('whoami').decode()}") + + try: + archinstall.SysCommand('nonexistingbinary-for-testing').decode().strip() + except archinstall.RequirementError: + pass # we want to make sure it fails with an exception unique to missing binary + + try: + archinstall.SysCommand('ls -veryfaultyparameter').decode().strip() + except archinstall.SysCallError: + pass # We want it to raise a syscall error when a binary dislikes us \ No newline at end of file