Skip to content

Commit

Permalink
add args for run_embedded_app subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
klmcadams committed Feb 5, 2025
1 parent 011dff7 commit 4063ae9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/embedding/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def test_tempfile_cleanup(tmp_path: pytest.TempPathFactory, run_subprocess):


@pytest.mark.embedding_scripts
def test_attribute_error(tmp_path: pytest.TempPathFactory, pytestconfig, rootdir, run_subprocess):
def test_attribute_error(tmp_path: pytest.TempPathFactory, pytestconfig, rootdir):
"""Test cleanup function to remove the temporary mechdb file and folder."""
# Change directory to tmp_path
os.chdir(tmp_path)
Expand All @@ -485,7 +485,7 @@ def test_attribute_error(tmp_path: pytest.TempPathFactory, pytestconfig, rootdir

# Run the script and assert the AttributeError is raised
stdout, stderr = subprocess.Popen(
[sys.executable, tmp_file_script, f"--version {version}"],
[sys.executable, tmp_file_script, "--version", version],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
).communicate()
Expand Down
66 changes: 60 additions & 6 deletions tests/embedding/test_appdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,33 @@
@pytest.mark.python_env
def test_private_appdata(pytestconfig, run_subprocess, rootdir):
"""Test embedded instance does not save ShowTriad using a test-scoped Python environment."""

version = pytestconfig.getoption("ansys_version")
embedded_py = os.path.join(rootdir, "tests", "scripts", "run_embedded_app.py")

run_subprocess([sys.executable, embedded_py, version, "True", "Set"])
process, stdout, stderr = run_subprocess([sys.executable, embedded_py, version, "True", "Run"])
run_subprocess(
[
sys.executable,
embedded_py,
"--version",
version,
"--private_appdata",
"True",
"--action",
"Set",
]
)
process, stdout, stderr = run_subprocess(
[
sys.executable,
embedded_py,
"--version",
version,
"--private_appdata",
"True",
"--action",
"Run",
]
)
stdout = stdout.decode()
assert "ShowTriad value is True" in stdout

Expand All @@ -54,9 +75,42 @@ def test_normal_appdata(pytestconfig, run_subprocess, rootdir):

embedded_py = os.path.join(rootdir, "tests", "scripts", "run_embedded_app.py")

run_subprocess([sys.executable, embedded_py, version, "False", "Set"])
process, stdout, stderr = run_subprocess([sys.executable, embedded_py, version, "False", "Run"])
run_subprocess([sys.executable, embedded_py, version, "False", "Reset"])
run_subprocess(
[
sys.executable,
embedded_py,
"--version",
version,
"--private_appdata",
"False",
"--action",
"Set",
]
)
process, stdout, stderr = run_subprocess(
[
sys.executable,
embedded_py,
"--version",
version,
"--private_appdata",
"False",
"--action",
"Run",
]
)
run_subprocess(
[
sys.executable,
embedded_py,
"--version",
version,
"--private_appdata",
"False",
"--action",
"Reset",
]
)

stdout = stdout.decode()
# Assert ShowTriad was set to False for regular embedded session
Expand Down

0 comments on commit 4063ae9

Please sign in to comment.