From 933d4e79f2380a5cab8dbe0d050f11dabbc50ea4 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:37:33 +0200 Subject: [PATCH] feat: allowing routines starting with /. --- src/ansys/mapdl/core/misc.py | 3 +++ tests/test_misc.py | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ansys/mapdl/core/misc.py b/src/ansys/mapdl/core/misc.py index d69c758ee3..2a4529bd5a 100644 --- a/src/ansys/mapdl/core/misc.py +++ b/src/ansys/mapdl/core/misc.py @@ -111,6 +111,9 @@ def check_valid_routine(routine): Raised when a routine is invalid. """ + if routine.lower().startswith("/"): + routine = routine[1:] + if routine.lower().startswith("begin"): return True if not hasattr(ROUTINES, routine.upper()): diff --git a/tests/test_misc.py b/tests/test_misc.py index defcd41fd8..b556dcafba 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -372,13 +372,17 @@ def myotherfun2(self): assert myclass.myotherfun2 is None -def test_check_valid_routine(): - assert check_valid_routine("prep7") - assert check_valid_routine("PREP7") - assert check_valid_routine("/PREP7") - assert check_valid_routine("begin level") +@pytest.mark.parametrize( + "routine", ["prep7", "PREP7", "/PREP7", "begin level", "BEGIN LEVEL"] +) +def test_check_valid_routine(routine): + assert check_valid_routine(routine) + + +@pytest.mark.parametrize("routine", ["invalid", "invalid routine", "prep78"]) +def test_check_valid_routine_invalid(routine): with pytest.raises(ValueError, match="Invalid routine"): - check_valid_routine("invalid") + check_valid_routine(routine) @requires("local")