From 149f99b1a9e54df0c708de042f2be4de5167a954 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 28 Jan 2022 01:02:16 +0100 Subject: [PATCH] Fixing ``CWD`` and failing tests (#860) * Fixing cwd when we return None and typo * Fixing unit tests * Fixing typo --- ansys/mapdl/core/mapdl.py | 7 ++++--- tests/test_mapdl.py | 8 ++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ansys/mapdl/core/mapdl.py b/ansys/mapdl/core/mapdl.py index af696c6d36..556b928fd3 100644 --- a/ansys/mapdl/core/mapdl.py +++ b/ansys/mapdl/core/mapdl.py @@ -448,7 +448,7 @@ def __enter__(self): self._parent()._store_commands = True def __exit__(self, *args): - self._parent()._log.debug("Entering non-interactive mode") + self._parent()._log.debug("Exiting non-interactive mode") self._parent()._flush_stored() class _chain_commands: @@ -2747,7 +2747,8 @@ def cwd(self, *args, **kwargs): """Wraps cwd""" returns_ = super().cwd( *args, **kwargs) - if '*** WARNING ***' in self._response: - warn('\n' + self._response) + if returns_: # if successful, it should be none. + if '*** WARNING ***' in self._response: + warn('\n' + self._response) return returns_ diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 707136f6cb..23541932e3 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -825,7 +825,6 @@ def test_cdread(mapdl, cleared): assert random_letters in mapdl.parameters['PARMTEST'] -# CDREAD tests are actually a good way to test 'input' command. @skip_in_cloud def test_cdread_different_location(mapdl, cleared, tmpdir): random_letters = mapdl.directory.split('/')[0][-3:0] @@ -948,25 +947,22 @@ def test_inval_commands_silent(mapdl, tmpdir, cleared): @skip_in_cloud def test_path_without_spaces(mapdl, path_tests): resp = mapdl.cwd(path_tests.path_without_spaces) - assert 'WARNING' not in resp + assert resp is None @skip_in_cloud def test_path_with_spaces(mapdl, path_tests): resp = mapdl.cwd(path_tests.path_with_spaces) - assert 'WARNING' not in resp + assert resp is None @skip_in_cloud def test_path_with_single_quote(mapdl, path_tests): with pytest.raises(RuntimeError): resp = mapdl.cwd(path_tests.path_with_single_quote) - assert 'WARNING' not in resp - @skip_in_cloud def test_cwd_directory(mapdl, tmpdir): - mapdl.directory = str(tmpdir) assert mapdl.directory == str(tmpdir).replace('\\', '/')