diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbd39d85017..54c35d4b0fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -262,11 +262,12 @@ jobs: with: latest-version: "252" mapdl-version: ${{ matrix.mapdl-version }} - testing-minimal: true + testing-minimal: false on-console: true pytest-arguments: '-k console' - file-name: "${{ matrix.mapdl-version }}-minimal-console" - tags: "local,minimal,console" + + file-name: "${{ matrix.mapdl-version }}-console" + tags: "local,console" test-windows: diff --git a/doc/changelog.d/3791.fixed.md b/doc/changelog.d/3791.fixed.md new file mode 100644 index 00000000000..7fb8bc2a51b --- /dev/null +++ b/doc/changelog.d/3791.fixed.md @@ -0,0 +1 @@ +fix: adding console testing \ No newline at end of file diff --git a/src/ansys/mapdl/core/launcher.py b/src/ansys/mapdl/core/launcher.py index 5e9c9fc9cde..c3896e3b664 100644 --- a/src/ansys/mapdl/core/launcher.py +++ b/src/ansys/mapdl/core/launcher.py @@ -2918,7 +2918,9 @@ def inject_additional_switches(args: dict[str, Any]) -> dict[str, Any]: if envvaras: if args.get("additional_switches"): - args["additional_switches"] += f" {envvaras}" + LOG.warning( + "Skipping injecting additional switches from env var if the function argument is used." + ) else: args["additional_switches"] = envvaras diff --git a/src/ansys/mapdl/core/mapdl_console.py b/src/ansys/mapdl/core/mapdl_console.py index d48c3609755..c320baeb27f 100644 --- a/src/ansys/mapdl/core/mapdl_console.py +++ b/src/ansys/mapdl/core/mapdl_console.py @@ -50,6 +50,8 @@ rb"executed\?", # errors rb"SHOULD INPUT PROCESSING BE SUSPENDED\?", + rb"ANSYS Traceback", + rb"eMPIChildJob", # prompts rb"ENTER FORMAT for", ] @@ -59,6 +61,7 @@ ERROR_IDX = ready_items.index(rb"SHOULD INPUT PROCESSING BE SUSPENDED\?") PROMPT_IDX = ready_items.index(rb"ENTER FORMAT for") + nitems = len(ready_items) expect_list = [] for item in ready_items: @@ -86,13 +89,13 @@ def launch_pexpect( nproc, additional_switches, ) - process = pexpect.spawn(command, cwd=run_location) + process = pexpect.spawn(command, cwd=run_location, use_poll=True) process.delaybeforesend = None try: index = process.expect(["BEGIN:", "CONTINUE"], timeout=start_timeout) - except: # capture failure - raise RuntimeError(process.before.decode("utf-8")) + except Exception as err: # capture failure + raise RuntimeError(process.before.decode("utf-8") or err) if index: # received ... press enter to continue process.sendline("") @@ -113,6 +116,7 @@ def __init__( log_apdl=None, use_vtk=True, print_com=False, + set_no_abort=True, **start_parm, ): """Opens an ANSYS process using pexpect""" @@ -122,6 +126,7 @@ def __init__( self._name = None self._session_id = None self._cleanup = None + self.clean_response = True self._launch(start_parm) super().__init__( @@ -132,6 +137,8 @@ def __init__( mode="console", **start_parm, ) + if set_no_abort: + self.nerr(abort=-1, mute=True) def _launch(self, start_parm): """Connect to MAPDL process using pexpect""" @@ -169,6 +176,19 @@ def _run(self, command, **kwargs): while True: i = self._process.expect_list(expect_list, timeout=None) response = self._process.before.decode("utf-8") + + if self.clean_response: + # Cleaning up responses + response = response.strip().splitlines() + if ( + isinstance(response, list) + and len(response) > 0 + and response[0].upper() == command.upper() + ): + response = response[1:] + + response = "\n".join(response) + full_response += response if i >= CONTINUE_IDX and i < WARNING_IDX: # continue self._log.debug( @@ -335,3 +355,10 @@ def name(self): if not self._name: self._name = f"Console_PID_{self._process.pid}" return self._name + + def scalar_param(self, parm_name): + response = self.starstatus(parm_name) + response = response.splitlines()[-1] + if parm_name.upper() not in response: + raise ValueError(f"Parameter {parm_name} not found") + return float(response.split()[1].strip()) diff --git a/src/ansys/mapdl/core/mapdl_extended.py b/src/ansys/mapdl/core/mapdl_extended.py index 58a321f3aa4..eb0f6ef18c5 100644 --- a/src/ansys/mapdl/core/mapdl_extended.py +++ b/src/ansys/mapdl/core/mapdl_extended.py @@ -50,6 +50,8 @@ supress_logging, ) +TMP_VAR = "__tmpvar__" + class _MapdlCommandExtended(_MapdlCore): """Class that extended MAPDL capabilities by wrapping or overwriting commands""" @@ -2123,6 +2125,126 @@ def cmlist(self, *args, **kwargs): return ComponentListing(super().cmlist(*args, **kwargs)) + @wraps(_MapdlCore.ndinqr) + def ndinqr(self, node, key, **kwargs): + """Wrap the ``ndinqr`` method to take advantage of the gRPC methods.""" + super().ndinqr(node, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.elmiqr) + def elmiqr(self, ielem, key, **kwargs): + """Wrap the ``elmiqr`` method to take advantage of the gRPC methods.""" + super().elmiqr(ielem, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.kpinqr) + def kpinqr(self, knmi, key, **kwargs): + """Wrap the ``kpinqr`` method to take advantage of the gRPC methods.""" + super().kpinqr(knmi, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.lsinqr) + def lsinqr(self, line, key, **kwargs): + """Wrap the ``lsinqr`` method to take advantage of the gRPC methods.""" + super().lsinqr(line, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.arinqr) + def arinqr(self, anmi, key, **kwargs): + """Wrap the ``arinqr`` method to take advantage of the gRPC methods.""" + super().arinqr(anmi, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.vlinqr) + def vlinqr(self, vnmi, key, **kwargs): + """Wrap the ``vlinqr`` method to take advantage of the gRPC methods.""" + super().vlinqr(vnmi, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.rlinqr) + def rlinqr(self, nreal, key, **kwargs): + """Wrap the ``rlinqr`` method to take advantage of the gRPC methods.""" + super().rlinqr(nreal, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.gapiqr) + def gapiqr(self, ngap, key, **kwargs): + """Wrap the ``gapiqr`` method to take advantage of the gRPC methods.""" + super().gapiqr(ngap, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.masiqr) + def masiqr(self, node, key, **kwargs): + """Wrap the ``masiqr`` method to take advantage of the gRPC methods.""" + super().masiqr(node, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.ceinqr) + def ceinqr(self, nce, key, **kwargs): + """Wrap the ``ceinqr`` method to take advantage of the gRPC methods.""" + super().ceinqr(nce, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.cpinqr) + def cpinqr(self, ncp, key, **kwargs): + """Wrap the ``cpinqr`` method to take advantage of the gRPC methods.""" + super().cpinqr(ncp, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.csyiqr) + def csyiqr(self, ncsy, key, **kwargs): + """Wrap the ``csyiqr`` method to take advantage of the gRPC methods.""" + super().csyiqr(ncsy, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.etyiqr) + def etyiqr(self, itype, key, **kwargs): + """Wrap the ``etyiqr`` method to take advantage of the gRPC methods.""" + super().etyiqr(itype, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.foriqr) + def foriqr(self, node, key, **kwargs): + """Wrap the ``foriqr`` method to take advantage of the gRPC methods.""" + super().foriqr(node, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.sectinqr) + def sectinqr(self, nsect, key, **kwargs): + """Wrap the ``sectinqr`` method to take advantage of the gRPC methods.""" + super().sectinqr(nsect, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.mpinqr) + def mpinqr(self, mat, iprop, key, **kwargs): + """Wrap the ``mpinqr`` method to take advantage of the gRPC methods.""" + super().mpinqr(mat, iprop, key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.dget) + def dget(self, node, idf, kcmplx, **kwargs): + """Wrap the ``dget`` method to take advantage of the gRPC methods.""" + super().dget(node, idf, kcmplx, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.fget) + def fget(self, node, idf, kcmplx, **kwargs): + """Wrap the ``fget`` method to take advantage of the gRPC methods.""" + super().fget(node, idf, kcmplx, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.erinqr) + def erinqr(self, key, **kwargs): + """Wrap the ``erinqr`` method to take advantage of the gRPC methods.""" + super().erinqr(key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + + @wraps(_MapdlCore.wrinqr) + def wrinqr(self, key, **kwargs): + """Wrap the ``wrinqr`` method to take advantage of the gRPC methods.""" + super().wrinqr(key, pname=TMP_VAR, mute=True, **kwargs) + return self.scalar_param(TMP_VAR) + class _MapdlExtended(_MapdlCommandExtended): """Extend Mapdl class with new functions""" diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index 7236e19b2c8..3a5d075a56c 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -108,7 +108,6 @@ from ansys.mapdl.core.database import MapdlDb from ansys.mapdl.core.xpl import ansXpl -TMP_VAR = "__tmpvar__" VOID_REQUEST = anskernel.EmptyRequest() # Default 256 MB message length @@ -3153,126 +3152,6 @@ def _distributed(self) -> bool: self.__distributed = self.parameters.numcpu > 1 return self.__distributed - @wraps(MapdlBase.ndinqr) - def ndinqr(self, node, key, **kwargs): - """Wrap the ``ndinqr`` method to take advantage of the gRPC methods.""" - super().ndinqr(node, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.elmiqr) - def elmiqr(self, ielem, key, **kwargs): - """Wrap the ``elmiqr`` method to take advantage of the gRPC methods.""" - super().elmiqr(ielem, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.kpinqr) - def kpinqr(self, knmi, key, **kwargs): - """Wrap the ``kpinqr`` method to take advantage of the gRPC methods.""" - super().kpinqr(knmi, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.lsinqr) - def lsinqr(self, line, key, **kwargs): - """Wrap the ``lsinqr`` method to take advantage of the gRPC methods.""" - super().lsinqr(line, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.arinqr) - def arinqr(self, anmi, key, **kwargs): - """Wrap the ``arinqr`` method to take advantage of the gRPC methods.""" - super().arinqr(anmi, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.vlinqr) - def vlinqr(self, vnmi, key, **kwargs): - """Wrap the ``vlinqr`` method to take advantage of the gRPC methods.""" - super().vlinqr(vnmi, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.rlinqr) - def rlinqr(self, nreal, key, **kwargs): - """Wrap the ``rlinqr`` method to take advantage of the gRPC methods.""" - super().rlinqr(nreal, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.gapiqr) - def gapiqr(self, ngap, key, **kwargs): - """Wrap the ``gapiqr`` method to take advantage of the gRPC methods.""" - super().gapiqr(ngap, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.masiqr) - def masiqr(self, node, key, **kwargs): - """Wrap the ``masiqr`` method to take advantage of the gRPC methods.""" - super().masiqr(node, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.ceinqr) - def ceinqr(self, nce, key, **kwargs): - """Wrap the ``ceinqr`` method to take advantage of the gRPC methods.""" - super().ceinqr(nce, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.cpinqr) - def cpinqr(self, ncp, key, **kwargs): - """Wrap the ``cpinqr`` method to take advantage of the gRPC methods.""" - super().cpinqr(ncp, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.csyiqr) - def csyiqr(self, ncsy, key, **kwargs): - """Wrap the ``csyiqr`` method to take advantage of the gRPC methods.""" - super().csyiqr(ncsy, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.etyiqr) - def etyiqr(self, itype, key, **kwargs): - """Wrap the ``etyiqr`` method to take advantage of the gRPC methods.""" - super().etyiqr(itype, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.foriqr) - def foriqr(self, node, key, **kwargs): - """Wrap the ``foriqr`` method to take advantage of the gRPC methods.""" - super().foriqr(node, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.sectinqr) - def sectinqr(self, nsect, key, **kwargs): - """Wrap the ``sectinqr`` method to take advantage of the gRPC methods.""" - super().sectinqr(nsect, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.mpinqr) - def mpinqr(self, mat, iprop, key, **kwargs): - """Wrap the ``mpinqr`` method to take advantage of the gRPC methods.""" - super().mpinqr(mat, iprop, key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.dget) - def dget(self, node, idf, kcmplx, **kwargs): - """Wrap the ``dget`` method to take advantage of the gRPC methods.""" - super().dget(node, idf, kcmplx, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.fget) - def fget(self, node, idf, kcmplx, **kwargs): - """Wrap the ``fget`` method to take advantage of the gRPC methods.""" - super().fget(node, idf, kcmplx, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.erinqr) - def erinqr(self, key, **kwargs): - """Wrap the ``erinqr`` method to take advantage of the gRPC methods.""" - super().erinqr(key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - - @wraps(MapdlBase.wrinqr) - def wrinqr(self, key, **kwargs): - """Wrap the ``wrinqr`` method to take advantage of the gRPC methods.""" - super().wrinqr(key, pname=TMP_VAR, mute=True, **kwargs) - return self.scalar_param(TMP_VAR) - @wraps(MapdlBase.file) def file(self, fname: str = "", ext: str = "", **kwargs) -> str: """Wrap ``MapdlBase.file`` to take advantage of the gRPC methods.""" diff --git a/tests/conftest.py b/tests/conftest.py index 65dbcd2caba..e9df3ff6688 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -574,6 +574,7 @@ def mapdl_console(request): mode="console", log_apdl="pymapdl.apdl" if DEBUG_TESTING else None, loglevel="DEBUG" if DEBUG_TESTING else "ERROR", + additional_switches="-smp", ) from ansys.mapdl.core.mapdl_console import MapdlConsole diff --git a/tests/test_console.py b/tests/test_console.py index 91588aab3b4..d728db61fe2 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -107,7 +107,7 @@ def test_comment(cleared, mapdl_console): def test_basic_command(cleared, mapdl_console): resp = mapdl_console.block(0, 1, 0, 1, 0, 1) - assert "CREATE A HEXAHEDRAL VOLUME" in resp + assert resp == 1 def test_allow_ignore(mapdl_console, cleared): @@ -126,13 +126,19 @@ def test_allow_ignore(mapdl_console, cleared): def test_chaining(mapdl_console, cleared): - mapdl_console.prep7() - n_kp = 1000 - with mapdl_console.chain_commands: - for i in range(1, 1 + n_kp): - mapdl_console.k(i, i, i, i) + # test chaining with distributed only + if mapdl_console._distributed: + with pytest.raises(MapdlRuntimeError): + with mapdl_console.chain_commands: + mapdl_console.prep7() + else: + mapdl_console.prep7() + n_kp = 1000 + with mapdl_console.chain_commands: + for i in range(1, 1 + n_kp): + mapdl_console.k(i, i, i, i) - assert mapdl_console.geometry.n_keypoint == 1000 + assert mapdl_console.geometry.n_keypoint == 1000 def test_e(mapdl_console, cleared): @@ -226,6 +232,7 @@ def test_al(cleared, mapdl_console): assert a0 == 1 +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_invalid_area(mapdl_console, cleared): with pytest.raises(MapdlRuntimeError): mapdl_console.a(0, 0, 0, 0) @@ -237,6 +244,7 @@ def test_invalid_area(mapdl_console, cleared): @requires("xserver") +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_kplot(cleared, mapdl_console, tmpdir): with pytest.raises(MapdlRuntimeError): mapdl_console.kplot(vtk=True) @@ -254,6 +262,7 @@ def test_kplot(cleared, mapdl_console, tmpdir): mapdl_console.kplot(knum=True, vtk=False) # make sure legacy still works +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") @requires("xserver") def test_aplot(cleared, mapdl_console): k0 = mapdl_console.k("", 0, 0, 0) @@ -275,6 +284,7 @@ def test_aplot(cleared, mapdl_console): mapdl_console.aplot(vtk=False) +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") @requires("xserver") @pytest.mark.parametrize("vtk", [True, False]) def test_vplot(cleared, mapdl_console, vtk): @@ -294,7 +304,7 @@ def test_keypoints(cleared, mapdl_console): i += 1 assert mapdl_console.geometry.n_keypoint == 4 - assert np.allclose(kps, mapdl_console.geometry.keypoints) + assert np.allclose(kps, mapdl_console.geometry.get_keypoints(return_as_array=True)) assert np.allclose(knum, mapdl_console.geometry.knum) @@ -311,12 +321,13 @@ def test_lines(cleared, mapdl_console): l3 = mapdl_console.l(k3, k0) lines = mapdl_console.geometry.lines - assert isinstance(lines, pyvista.PolyData) + assert isinstance(lines, pyvista.MultiBlock) assert np.allclose(mapdl_console.geometry.lnum, [l0, l1, l2, l3]) assert mapdl_console.geometry.n_line == 4 @requires("xserver") +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_lplot(cleared, mapdl_console, tmpdir): with pytest.raises(MapdlRuntimeError): mapdl_console.lplot(vtk=True) @@ -385,6 +396,7 @@ def test_nodes(tmpdir, cleared, mapdl_console): assert not mapdl_console.mesh.nnum.size +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_enum(mapdl_console, make_block): assert mapdl_console.mesh.n_elem assert np.allclose(mapdl_console.mesh.enum, range(1, mapdl_console.mesh.n_elem + 1)) @@ -392,6 +404,7 @@ def test_enum(mapdl_console, make_block): @pytest.mark.parametrize("knum", [True, False]) @requires("xserver") +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_nplot_vtk(cleared, mapdl_console, knum): with pytest.raises(MapdlRuntimeError): mapdl_console.nplot() @@ -403,6 +416,7 @@ def test_nplot_vtk(cleared, mapdl_console, knum): @requires("xserver") +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_nplot(cleared, mapdl_console): mapdl_console.n(1, 0, 0, 0) mapdl_console.n(11, 10, 0, 0) @@ -410,6 +424,7 @@ def test_nplot(cleared, mapdl_console): mapdl_console.nplot(vtk=False, background="w", color="k") +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_elements(cleared, mapdl_console): mapdl_console.et(1, 185) @@ -436,7 +451,7 @@ def test_elements(cleared, mapdl_console): [0, 1, 3], ] - with mapdl_console.chain_commands: + with mapdl_console.non_interactive: for cell in [cell1, cell2]: for x, y, z in cell: mapdl_console.n(x=x, y=y, z=z) @@ -515,6 +530,7 @@ def test_builtin_parameters(mapdl_console, cleared): assert mapdl_console.parameters.real == 1 +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_eplot_fail(mapdl_console, cleared): # must fail with empty mesh with pytest.raises(MapdlRuntimeError): @@ -522,6 +538,7 @@ def test_eplot_fail(mapdl_console, cleared): @requires("xserver") +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_eplot(mapdl_console, make_block): init_elem = mapdl_console.mesh.n_elem mapdl_console.aplot() # check aplot and verify it doesn't mess up the element plotting @@ -531,6 +548,7 @@ def test_eplot(mapdl_console, make_block): @requires("xserver") +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_eplot_screenshot(mapdl_console, make_block, tmpdir): filename = str(tmpdir.mkdir("tmpdir").join("tmp.png")) mapdl_console.eplot( @@ -566,6 +584,7 @@ def test_cyclic_solve(mapdl_console, cleared): assert mapdl_console.result.nsets == 16 +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_partial_mesh_nnum(mapdl_console, make_block): allsel_nnum_old = mapdl_console.mesh.nnum mapdl_console.nsel("S", "NODE", vmin=100, vmax=200) @@ -576,7 +595,8 @@ def test_partial_mesh_nnum(mapdl_console, make_block): assert np.allclose(allsel_nnum_old, mapdl_console.mesh.nnum) -def test_partial_mesh_nnum(mapdl_console, make_block): +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") +def test_partial_mesh_n_cells(mapdl_console, make_block): mapdl_console.nsel("S", "NODE", vmin=1, vmax=10) mapdl_console.esel("S", "ELEM", vmin=10, vmax=20) assert mapdl_console.mesh._grid.n_cells == 11 @@ -624,7 +644,7 @@ def test_load_table(mapdl_console, cleared): def test_mode_console(mapdl_console, cleared): - assert mapdl_console.mode == "console" + assert mapdl_console._mode == "console" assert not mapdl_console.is_grpc assert not mapdl_console.is_corba assert mapdl_console.is_console @@ -708,3 +728,23 @@ def test_exit_console(mapdl_console, close_log): mock_close_log.assert_not_called() mock_exit.assert_called_once() + assert mapdl_console._exited + + # restoring state + mapdl_console._exited = False + + +@pytest.mark.parametrize("command", ["FINISH", "/PREP7", "/SOLU"]) +def test_not_command_in_response(mapdl_console, cleared, command): + resp = mapdl_console.run(command) + + assert command not in resp + + +@pytest.mark.parametrize("command", ["FINISH", "/PREP7", "/SOLU"]) +def test_command_in_response(mapdl_console, cleared, command): + mapdl_console.clean_response = False + resp = mapdl_console.run(command, clean_response=False) + mapdl_console.clean_response = True + + assert command in resp diff --git a/tests/test_launcher.py b/tests/test_launcher.py index e253a1fd330..ad871022a75 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -284,8 +284,9 @@ def test_not_valid_versions(mapdl, my_fs, cleared, monkeypatch, version): @requires("local") @requires("linux") @requires("console") +@pytest.mark.skipif(True, reason="Skipping this console test. See issue #3791") def test_failed_console(): - exec_file = find_mapdl(installed_mapdl_versions[0])[0] + exec_file = find_mapdl(str(installed_mapdl_versions[0]))[0] with pytest.raises(ValueError): pymapdl.launch_mapdl(exec_file, mode="console", start_timeout=start_timeout) @@ -2094,4 +2095,5 @@ def test_inject_additional_switches(monkeypatch): new_args = inject_additional_switches(args) assert args["additional_switches"] in new_args["additional_switches"] - assert envvar in new_args["additional_switches"] + # The env var is ignored if the argument is used + assert envvar not in new_args["additional_switches"]