diff --git a/doc/changelog.d/1029.fixed.md b/doc/changelog.d/1029.fixed.md new file mode 100644 index 000000000..7996cc7e0 --- /dev/null +++ b/doc/changelog.d/1029.fixed.md @@ -0,0 +1 @@ +Process return code \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 6b19895be..cd4565b9a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -176,17 +176,20 @@ def mke_app_reset(request): EMBEDDED_APP.new() -_CHECK_PROCESS_RETURN_CODE = os.name == "nt" - # set to True if you want to see all the subprocess stdout/stderr _PRINT_SUBPROCESS_OUTPUT_TO_CONSOLE = False @pytest.fixture() -def run_subprocess(): +def run_subprocess(pytestconfig): + version = pytestconfig.getoption("ansys_version") + def func(args, env=None, check: bool = None): if check is None: - check = _CHECK_PROCESS_RETURN_CODE + check = True + if os.name != "nt": + if int(version) < 251: + check = False process, output = ansys.mechanical.core.run._run( args, env, check, _PRINT_SUBPROCESS_OUTPUT_TO_CONSOLE ) diff --git a/tests/embedding/test_logger.py b/tests/embedding/test_logger.py index 76242b671..c0ef1435f 100644 --- a/tests/embedding/test_logger.py +++ b/tests/embedding/test_logger.py @@ -57,14 +57,16 @@ def _run_embedding_log_test( embedded_py = os.path.join(rootdir, "tests", "scripts", "embedding_log_test.py") subprocess_pass_expected = pass_expected - if pass_expected == True and os.name != "nt" and int(version) < 251: - subprocess_pass_expected = False + if pass_expected == True: + if os.name != "nt" and int(version) < 251: + subprocess_pass_expected = False - process, stdout, stderr = run_subprocess( + _, stdout, stderr = run_subprocess( [sys.executable, embedded_py, version, testname], _get_env_without_logging_variables(), subprocess_pass_expected, ) + if not subprocess_pass_expected: stdout = stdout.decode() _assert_success(stdout, pass_expected)