Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit 803330e

Browse files
authored
Using an env var to specify if ansys is local or not. (#31)
Adding skipif to tests that require ansys to be installed
1 parent cc89e56 commit 803330e

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.github/workflows/ci_cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
username: ${{ secrets.GH_USERNAME }}
5656
password: ${{ secrets.GITHUB_TOKEN }}
5757
env:
58-
ON_LOCAL: true
58+
ANSYS_LOCAL: true
5959
ON_UBUNTU: true
6060

6161
steps:

tests/test_metadata.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
from ansys.tools.path import __version__
24

35

@@ -12,3 +14,12 @@ def test_pkg_version():
1214
read_version = importlib_metadata.version("ansys-tools-path")
1315

1416
assert __version__ == read_version
17+
18+
19+
def test_cicd_envvar():
20+
if not os.environ.get("ANSYS_LOCAL", ""):
21+
# env var does not exists
22+
raise RuntimeError(
23+
"The env var 'ANSYS_LOCAL' does not exists. That env var is needed to tell Pytest which\n"
24+
"tests should be run depending on if MAPDL is installed ('ANSYS_LOCAL'=True) or not."
25+
)

tests/test_path.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@
2323
]
2424

2525

26+
skip_if_ansys_not_local = pytest.mark.skipif(
27+
os.environ.get("ANSYS_LOCAL", "").upper() != "TRUE", reason="Skipping on CI"
28+
)
29+
30+
2631
@pytest.mark.parametrize("path_data", paths)
2732
def test_mapdl_version_from_path(path_data):
2833
exec_file, version = path_data
2934
assert version_from_path("mapdl", exec_file) == version
3035

3136

37+
@skip_if_ansys_not_local
3238
def test_find_mapdl_linux():
3339
# assuming Ansys MAPDL is installed, should be able to find it on linux
3440
# without env var
@@ -37,6 +43,7 @@ def test_find_mapdl_linux():
3743
assert isinstance(ver, float)
3844

3945

46+
@skip_if_ansys_not_local
4047
def test_migration():
4148
"""If the user configuration the mapdl path using pymapdl before
4249
ansys-tools-path, ansys-tools-path should respect it."""
@@ -53,10 +60,12 @@ def test_migration():
5360
assert not os.path.isfile(old_config_file)
5461

5562

63+
@skip_if_ansys_not_local
5664
def test_get_available_base_mapdl():
5765
assert get_available_ansys_installations()
5866

5967

68+
@skip_if_ansys_not_local
6069
def test_is_valid_mapdl_executable_path():
6170
path = get_available_ansys_installations().values()
6271
path = list(path)[0]
@@ -78,6 +87,7 @@ def test_change_default_mapdl_path():
7887
change_default_mapdl_path("asdf")
7988

8089

90+
@skip_if_ansys_not_local
8191
def test_save_mapdl_path():
8292
_clear_config_file()
8393

@@ -93,6 +103,7 @@ def test_warn_uncommon_executable_path():
93103
_check_uncommon_executable_path("mapdl", "qwer")
94104

95105

106+
@skip_if_ansys_not_local
96107
def test_get_mapdl_path():
97108
assert get_mapdl_path()
98109
assert get_mapdl_path(version=222)

0 commit comments

Comments
 (0)