1313 is_valid_executable_path ,
1414 launch_mapdl ,
1515 save_ansys_path ,
16+ update_env_vars ,
1617 warn_uncommon_executable_path ,
1718)
1819from ansys .mapdl .core .licensing import LICENSES
5051
5152V150_EXEC = get_ansys_bin ("150" )
5253
53- if not valid_versions :
54- pytestmark = pytest .mark .skip ("Requires MAPDL" )
55-
5654paths = [
5755 ("/usr/dir_v2019.1/slv/ansys_inc/v211/ansys/bin/ansys211" , 211 ),
5856 ("C:/Program Files/ANSYS Inc/v202/ansys/bin/win64/ANSYS202.exe" , 202 ),
6361@pytest .mark .skipif (
6462 not get_start_instance (), reason = "Skip when start instance is disabled"
6563)
64+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
6665@pytest .mark .skipif (os .name != "nt" , reason = "Requires Windows" )
6766def test_validate_sw ():
6867 # ensure that windows adds msmpi
@@ -75,6 +74,7 @@ def test_validate_sw():
7574@pytest .mark .skipif (
7675 not get_start_instance (), reason = "Skip when start instance is disabled"
7776)
77+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
7878@pytest .mark .parametrize ("path_data" , paths )
7979def test_version_from_path (path_data ):
8080 exec_file , version = path_data
@@ -84,6 +84,7 @@ def test_version_from_path(path_data):
8484@pytest .mark .skipif (
8585 not get_start_instance (), reason = "Skip when start instance is disabled"
8686)
87+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
8788def test_catch_version_from_path ():
8889 with pytest .raises (RuntimeError ):
8990 _version_from_path ("abc" )
@@ -92,8 +93,8 @@ def test_catch_version_from_path():
9293@pytest .mark .skipif (
9394 not get_start_instance (), reason = "Skip when start instance is disabled"
9495)
96+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
9597@pytest .mark .skipif (os .name != "posix" , reason = "Requires Linux" )
96- @pytest .mark .skipif (not versions , reason = "Requires ANSYS install" )
9798def test_find_ansys_linux ():
9899 # assuming ansys is installed, should be able to find it on linux
99100 # without env var
@@ -105,6 +106,7 @@ def test_find_ansys_linux():
105106@pytest .mark .skipif (
106107 not get_start_instance (), reason = "Skip when start instance is disabled"
107108)
109+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
108110def test_invalid_mode ():
109111 with pytest .raises (ValueError ):
110112 exec_file = get_ansys_bin (valid_versions [0 ])
@@ -114,6 +116,7 @@ def test_invalid_mode():
114116@pytest .mark .skipif (
115117 not get_start_instance (), reason = "Skip when start instance is disabled"
116118)
119+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
117120@pytest .mark .skipif (not os .path .isfile (V150_EXEC ), reason = "Requires v150" )
118121def test_old_version ():
119122 exec_file = get_ansys_bin ("150" )
@@ -124,6 +127,7 @@ def test_old_version():
124127@pytest .mark .skipif (
125128 not get_start_instance (), reason = "Skip when start instance is disabled"
126129)
130+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
127131@pytest .mark .skipif (not os .name == "nt" , reason = "Requires windows" )
128132@pytest .mark .console
129133def test_failed_console ():
@@ -135,6 +139,7 @@ def test_failed_console():
135139@pytest .mark .skipif (
136140 not get_start_instance (), reason = "Skip when start instance is disabled"
137141)
142+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
138143@pytest .mark .parametrize ("version" , valid_versions )
139144@pytest .mark .console
140145@pytest .mark .skipif (os .name != "posix" , reason = "Only supported on Linux" )
@@ -147,6 +152,7 @@ def test_launch_console(version):
147152@pytest .mark .skipif (
148153 not get_start_instance (), reason = "Skip when start instance is disabled"
149154)
155+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
150156@pytest .mark .corba
151157@pytest .mark .parametrize ("version" , valid_versions )
152158def test_launch_corba (version ):
@@ -163,6 +169,7 @@ def test_launch_corba(version):
163169@pytest .mark .skipif (
164170 not get_start_instance (), reason = "Skip when start instance is disabled"
165171)
172+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
166173def test_license_type_keyword ():
167174 # This test might became a way to check available licenses, which is not the purpose.
168175
@@ -189,6 +196,7 @@ def test_license_type_keyword():
189196@pytest .mark .skipif (
190197 not get_start_instance (), reason = "Skip when start instance is disabled"
191198)
199+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
192200def test_license_type_keyword_names ():
193201 # This test might became a way to check available licenses, which is not the purpose.
194202
@@ -209,6 +217,7 @@ def test_license_type_keyword_names():
209217@pytest .mark .skipif (
210218 not get_start_instance (), reason = "Skip when start instance is disabled"
211219)
220+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
212221def test_license_type_additional_switch ():
213222 # This test might became a way to check available licenses, which is not the purpose.
214223 successful_check = False
@@ -233,6 +242,7 @@ def test_license_type_additional_switch():
233242 mapdl .exit ()
234243
235244
245+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
236246@pytest .mark .parametrize (
237247 "exe_loc" ,
238248 [
@@ -246,6 +256,7 @@ def test_save_ansys_path(exe_loc):
246256 assert os .path .exists (path_ )
247257
248258
259+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
249260@pytest .mark .parametrize (
250261 "file,result" ,
251262 [
@@ -265,6 +276,7 @@ def test_is_valid_executable_path(tmpdir, file, result):
265276 assert is_valid_executable_path (filename ) == result
266277
267278
279+ @pytest .mark .skipif (not valid_versions , reason = "Requires MAPDL installed." )
268280@pytest .mark .parametrize (
269281 "file_path,result" ,
270282 [
@@ -301,6 +313,26 @@ def test_warn_uncommon_executable_path():
301313 warn_uncommon_executable_path ("" )
302314
303315
316+ def test_env_injection ():
317+
318+ assert update_env_vars (None , None ) is None
319+
320+ assert "myenvvar" in update_env_vars ({"myenvvar" : "True" }, None )
321+
322+ _env_vars = update_env_vars (None , {"myenvvar" : "True" })
323+ assert len (_env_vars ) == 1
324+ assert "myenvvar" in _env_vars
325+
326+ with pytest .raises (ValueError ):
327+ update_env_vars ({"myenvvar" : "True" }, {"myenvvar" : "True" })
328+
329+ with pytest .raises (TypeError ):
330+ update_env_vars ("asdf" , None )
331+
332+ with pytest .raises (TypeError ):
333+ update_env_vars (None , "asdf" )
334+
335+
304336@pytest .mark .requires_gui
305337def test_open_gui (mapdl ):
306338
0 commit comments