From f01e8f761d8f0ad26bddabf5d0b397223249c135 Mon Sep 17 00:00:00 2001 From: German Date: Fri, 15 Dec 2023 22:51:36 +0100 Subject: [PATCH] Adding tests to deprecated commands --- src/ansys/mapdl/core/errors.py | 2 +- tests/test_mapdl.py | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/ansys/mapdl/core/errors.py b/src/ansys/mapdl/core/errors.py index 85a396eb15..38be4515bd 100644 --- a/src/ansys/mapdl/core/errors.py +++ b/src/ansys/mapdl/core/errors.py @@ -266,7 +266,7 @@ def __init__(self, msg=""): MapdlException.__init__(self, msg) -class CommandDeprecated(MapdlException): +class CommandDeprecated(MapdlException, DeprecationError): """Raised when a command is deprecated""" def __init__(self, msg=""): diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index aac3084bbc..5fc66767af 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -22,6 +22,7 @@ from ansys.mapdl import core as pymapdl from ansys.mapdl.core.commands import CommandListingOutput from ansys.mapdl.core.errors import ( + CommandDeprecated, IncorrectWorkingDirectory, MapdlCommandIgnoredError, MapdlConnectionError, @@ -36,6 +37,67 @@ PATH = os.path.dirname(os.path.abspath(__file__)) test_files = os.path.join(PATH, "test_files") +DEPRECATED_COMMANDS = [ + "edasmp", + "edbound", + "edbx", + "edcgen", + "edclist", + "edcmore", + "edcnstr", + "edcontact", + "edcrb", + "edcurve", + "eddbl", + "eddc", + "edipart", + "edlcs", + "edmp", + "ednb", + "edndtsd", + "ednrot", + "edpart", + "edpc", + "edsp", + "edweld", + "edadapt", + "edale", + "edbvis", + "edcadapt", + "edcpu", + "edcsc", + "edcts", + "eddamp", + "eddrelax", + "eddump", + "edenergy", + "edfplot", + "edgcale", + "edhgls", + "edhist", + "edhtime", + "edint", + "edis", + "edload", + "edopt", + "edout", + "edpl", + "edpvel", + "edrc", + "edrd", + "edri", + "edrst", + "edrun", + "edshell", + "edsolv", + "edstart", + "edterm", + "edtp", + "edvel", + "edwrite", + "rexport", +] + CMD_BLOCK = """/prep7 ! Mat MP,EX,1,200000 @@ -157,6 +219,13 @@ def warns_in_cdread_error_log(mapdl, tmpdir): return any(warns) +@pytest.mark.parametrize("command", DEPRECATED_COMMANDS) +def test_deprecated_commands(mapdl, command): + with pytest.raises(CommandDeprecated): + method = getattr(mapdl, command) + method() + + @requires("grpc") def test_internal_name_grpc(mapdl): assert str(mapdl._ip) in mapdl.name