Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking mapdl.print_com behavior to mapdl.mute #873

Merged
merged 3 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansys/mapdl/core/_commands/session/list_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def com(self, comment="", **kwargs):
This command is valid anywhere.
"""
command = "/COM,%s" % (str(comment))
if self.print_com:
if self.print_com and not self.mute and not kwargs.get('mute', False):
print(command)
return self.run(command, **kwargs)

Expand Down
24 changes: 23 additions & 1 deletion tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,17 +1076,39 @@ def test_print_com(mapdl, capfd):
mapdl.print_com = True
string_ = "Testing print"
mapdl.com(string_)

out, err = capfd.readouterr()
assert string_ in out

mapdl.print_com = False
string_ = "Testing disabling print"
mapdl.com(string_)
out, err = capfd.readouterr()
assert string_ not in out

mapdl.print_com = True
mapdl.mute = True
mapdl.com(string_)
out, err = capfd.readouterr()
assert string_ not in out

mapdl.print_com = True
mapdl.mute = False
mapdl.com(string_, mute=True)
out, err = capfd.readouterr()
assert string_ not in out

mapdl.print_com = True
mapdl.mute = True
mapdl.com(string_, mute=True)
out, err = capfd.readouterr()
assert string_ not in out

mapdl.print_com = True
mapdl.mute = False
mapdl.com(string_, mute=False)
out, err = capfd.readouterr()
assert string_ in out

# Not allowed type for mapdl.print_com
for each in ['asdf', (1, 2), 2, []]:
with pytest.raises(ValueError):
Expand Down