Skip to content

Commit

Permalink
fix: Process return code (#1029)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohamed Koubaa <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: pyansys-ci-bot <[email protected]>
  • Loading branch information
4 people authored Jan 7, 2025
1 parent 009b819 commit 924d476
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/1029.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Process return code
11 changes: 7 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
8 changes: 5 additions & 3 deletions tests/embedding/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 924d476

Please sign in to comment.