Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Process return code #1029

Merged
merged 7 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading