Skip to content

Commit

Permalink
Fixing CWD and failing tests (#860)
Browse files Browse the repository at this point in the history
* Fixing cwd when we return None and typo

* Fixing unit tests

* Fixing typo
  • Loading branch information
germa89 authored Jan 28, 2022
1 parent 406bed8 commit 149f99b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 4 additions & 3 deletions ansys/mapdl/core/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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_
8 changes: 2 additions & 6 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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('\\', '/')

Expand Down

0 comments on commit 149f99b

Please sign in to comment.