From 36cb7edd83af32fecd269c840be25c2a0e6fd1f4 Mon Sep 17 00:00:00 2001
From: Hans Fangohr <hans.fangohr@mpsd.mpg.de>
Date: Wed, 31 May 2023 12:38:19 +0200
Subject: [PATCH] check exceptions are raised (as for subprocess.run)

---
 tests.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests.py b/tests.py
index d3652a4..b79ccf1 100644
--- a/tests.py
+++ b/tests.py
@@ -45,6 +45,16 @@ def test_run_method(tmp_path):
             in run(["echo", "Hello, world!"], capture_output=True).stdout
         )
 
+    # check exceptions
+    with pytest.raises(FileNotFoundError):
+        run(["doesnotexistcommand"])
+
+    # check error code is checked
+    # 1. expect this to parse: return code is non-zero, but we don't check
+    run(["ls", "/doesnotexist"]),
+    # 2. expect this to fail:
+    with pytest.raises(subprocess.CalledProcessError):
+        run(["ls", "/doesnotexist"], check=True)
 
 
 def test_prepare_environment(tmp_path):
-- 
GitLab