From 6cf1cfafc7d3489b2a80a939a39452cfa69df6da Mon Sep 17 00:00:00 2001 From: German Date: Tue, 1 Feb 2022 01:49:59 +0100 Subject: [PATCH 1/3] Adding changes. --- ansys/mapdl/core/_commands/session/list_controls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansys/mapdl/core/_commands/session/list_controls.py b/ansys/mapdl/core/_commands/session/list_controls.py index 5118de63b1..1ff2293d9d 100644 --- a/ansys/mapdl/core/_commands/session/list_controls.py +++ b/ansys/mapdl/core/_commands/session/list_controls.py @@ -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) From 0d5aaedcb200d94d8a783f8fdd9f6c6d905c2fc4 Mon Sep 17 00:00:00 2001 From: German Date: Tue, 1 Feb 2022 01:50:06 +0100 Subject: [PATCH 2/3] Adding unit tests --- tests/test_mapdl.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 2bffa8dae0..6d259b1a2a 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -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): From 6b0ae1f76d7e0cd27fe370d69fb39435cf5c73b7 Mon Sep 17 00:00:00 2001 From: German Date: Tue, 1 Feb 2022 01:53:05 +0100 Subject: [PATCH 3/3] fixing trailing space --- tests/test_mapdl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 6d259b1a2a..18385771c5 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -1095,7 +1095,7 @@ def test_print_com(mapdl, capfd): mapdl.mute = False mapdl.com(string_, mute=True) out, err = capfd.readouterr() - assert string_ not in out + assert string_ not in out mapdl.print_com = True mapdl.mute = True