From 9babee41756ea19e1707ffd6587f2406ee4efe82 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Tue, 10 Oct 2023 18:54:21 +0100 Subject: [PATCH] fixes test Signed-off-by: Wenqi Li --- tests/test_integration_bundle_run.py | 10 ++++------ tests/utils.py | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_integration_bundle_run.py b/tests/test_integration_bundle_run.py index fb9e0e75c6..bd96f50c55 100644 --- a/tests/test_integration_bundle_run.py +++ b/tests/test_integration_bundle_run.py @@ -86,9 +86,8 @@ def test_tiny(self): with self.assertRaises(RuntimeError): # test wrong run_id="run" command_line_tests(cmd + ["run", "run", "--config_file", config_file]) - with self.assertRaises(RuntimeError): - # test missing meta file - command_line_tests(cmd + ["run", "training", "--config_file", config_file]) + # test missing meta file + self.assertIn("ERROR", command_line_tests(cmd + ["run", "training", "--config_file", config_file])) def test_scripts_fold(self): # test scripts directory has been added to Python search directories automatically @@ -150,9 +149,8 @@ def test_scripts_fold(self): print(output) self.assertTrue(expected_condition in output) - with self.assertRaises(RuntimeError): - # test missing meta file - command_line_tests(cmd + ["run", "training", "--config_file", config_file]) + # test missing meta file + self.assertIn("ERROR", command_line_tests(cmd + ["run", "training", "--config_file", config_file])) @parameterized.expand([TEST_CASE_1, TEST_CASE_2]) def test_shape(self, config_file, expected_shape): diff --git a/tests/utils.py b/tests/utils.py index 9f2b41adb7..a8efbe081e 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -818,6 +818,7 @@ def command_line_tests(cmd, copy_env=True): try: normal_out = subprocess.run(cmd, env=test_env, check=True, capture_output=True) print(repr(normal_out).replace("\\n", "\n").replace("\\t", "\t")) + return repr(normal_out) except subprocess.CalledProcessError as e: output = repr(e.stdout).replace("\\n", "\n").replace("\\t", "\t") errors = repr(e.stderr).replace("\\n", "\n").replace("\\t", "\t")