def mapdl_corba(request): ansys_base_paths = _get_available_base_ansys() # find a valid version of corba corba_path = None for version in ansys_base_paths: if version >= 170 and version < 202: corba_path = get_ansys_bin(str(version)) if corba_path is None: raise RuntimeError( '"-corba" testing option unavailable.' "No local CORBA compatible MAPDL installation found. " "Valid versions are ANSYS 17.0 up to 2020R2.") mapdl = launch_mapdl(corba_path) from ansys.mapdl.core.mapdl_corba import MapdlCorba assert isinstance(mapdl, MapdlCorba) mapdl._show_matplotlib_figures = False # CI: don't show matplotlib figures # using yield rather than return here to be able to test exit yield mapdl # verify mapdl exits mapdl.exit() assert mapdl._exited assert "MAPDL exited" in str(mapdl) with pytest.raises(MapdlExitedError): mapdl.prep7()
def mapdl_console(request): if os.name != "posix": raise RuntimeError('"--console" testing option unavailable. ' "Only Linux is supported.") ansys_base_paths = _get_available_base_ansys() # find a valid version of corba console_path = None for version in ansys_base_paths: if version < 211: console_path = get_ansys_bin(str(version)) if console_path is None: raise RuntimeError( '"--console" testing option unavailable.' "No local console compatible MAPDL installation found. " "Valid versions are up to 2020R2.") mapdl = launch_mapdl(console_path) from ansys.mapdl.core.mapdl_console import MapdlConsole assert isinstance(mapdl, MapdlConsole) mapdl._show_matplotlib_figures = False # CI: don't show matplotlib figures # using yield rather than return here to be able to test exit yield mapdl # verify mapdl exits mapdl.exit() assert mapdl._exited assert "MAPDL exited" in str(mapdl) with pytest.raises(MapdlExitedError): mapdl.prep7()
def test_launch_corba(version): mapdl = pymapdl.launch_mapdl(get_ansys_bin(version), mode="corba") assert mapdl.version == int(version) / 10 # mapdl.exit() # exit is already tested for in test_mapdl.py. # Instead, test collection mapdl_ref = weakref.ref(mapdl) del mapdl assert mapdl_ref() is None
def mapdl(request): """This fixture will only be called if ``ansys.mapdl.core`` is installed.""" from ansys.mapdl.core import launch_mapdl from ansys.mapdl.core.misc import get_ansys_bin from ansys.mapdl.core.launcher import get_start_instance # check if the user wants to permit pytest to start MAPDL # and don't allow mapdl to exit upon collection unless mapdl is local cleanup = get_start_instance() # check for a valid MAPDL install with gRPC valid_rver = ['211'] # checks in this order EXEC_FILE = None for rver in valid_rver: if os.path.isfile(get_ansys_bin(rver)): EXEC_FILE = get_ansys_bin(rver) break return launch_mapdl(EXEC_FILE, override=True, cleanup_on_exit=cleanup)
def test_old_version(): exec_file = get_ansys_bin("150") with pytest.raises(ValueError): pymapdl.launch_mapdl(exec_file, mode="corba")
def test_invalid_mode(): with pytest.raises(ValueError): exec_file = get_ansys_bin(valid_versions[0]) pymapdl.launch_mapdl(exec_file, mode="notamode")
def test_launch_console(version): exec_file = get_ansys_bin(version) mapdl = pymapdl.launch_mapdl(exec_file, mode="console") assert mapdl.version == int(version) / 10
def test_failed_console(): exec_file = get_ansys_bin(valid_versions[0]) with pytest.raises(ValueError): pymapdl.launch_mapdl(exec_file, mode="console")
"182", # 18.2 "190", # 19.0 "191", # 19.1 "192", # 19.2 "193", # 2019R1 "194", # 2019R2 "195", # 2019R3 "201", # 2020R1 "202", # 2020R2 "211", # 2021R1 "212", # 2021R2 ] valid_versions = [] for version in versions: exec_file = get_ansys_bin(version) if os.path.isfile(get_ansys_bin(version)): valid_versions.append(version) V150_EXEC = get_ansys_bin("150") # skip entire module when using static server if not get_start_instance(): pytest.skip("Skip when start instance is disabled", allow_module_level=True) if not valid_versions: pytestmark = pytest.mark.skip("Requires MAPDL") paths = [ ("/usr/dir_v2019.1/slv/ansys_inc/v211/ansys/bin/ansys211", 211),
from pathlib import Path import os import time import numpy as np import pytest from ansys.mapdl.core.misc import get_ansys_bin from ansys.mapdl.core import LocalMapdlPool, examples from ansys.mapdl.core.launcher import get_start_instance # check for a valid MAPDL install with gRPC valid_rver = ['211'] EXEC_FILE = None for rver in valid_rver: if os.path.isfile(get_ansys_bin(rver)): EXEC_FILE = get_ansys_bin(rver) break IGNORE_POOL = os.environ.get('IGNORE_POOL', '').upper() == 'TRUE' skip_launch_mapdl = pytest.mark.skipif( get_start_instance() is False or IGNORE_POOL, reason="Must be able to launch MAPDL locally") TWAIT = 90 @pytest.fixture(scope="module") def pool(): mapdl_pool = LocalMapdlPool(4, exec_file=EXEC_FILE)