From 83e678dbe8ff5ad94619879e52b2a56367f7129b Mon Sep 17 00:00:00 2001 From: ElliottKasoar Date: Mon, 22 Jan 2024 16:25:13 +0000 Subject: [PATCH] Catch process errors in CLI tests --- tests/cli.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/cli.py b/tests/cli.py index 4149ecc8..40820251 100644 --- a/tests/cli.py +++ b/tests/cli.py @@ -1,4 +1,5 @@ import os +import subprocess import unittest import logging from time import sleep @@ -26,16 +27,19 @@ def setUpClass(cls): if not cls.security_enabled: url += " --disable_ssl" try: - os.system(f"abcd login {url}") - except (ConnectionError, ConnectionResetError): + subprocess.run(f"abcd login {url}", shell=True, check=True) + except subprocess.CalledProcessError: sleep(10) - os.system(f"abcd login {url}") + subprocess.run(f"abcd login {url}", shell=True, check=True) def test_summary(self): """ - Test summary output of stored data. + Test summary output of uploaded data file. """ class_path = os.path.normpath(os.path.abspath(__file__)) data_file = os.path.dirname(class_path) + "/data/example.xyz" - os.system(f"abcd upload {data_file}") - os.system("abcd summary") + subprocess.run(f"abcd upload {data_file}", shell=True, check=True) + summary = subprocess.run( + "abcd summary", shell=True, check=True, capture_output=True, text=True + ) + assert "Total number of configurations: 1" in summary.stdout