Skip to content

Commit

Permalink
feat: allowing routines starting with /.
Browse files Browse the repository at this point in the history
  • Loading branch information
germa89 committed Aug 27, 2024
1 parent 21a642e commit 933d4e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/ansys/mapdl/core/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down
16 changes: 10 additions & 6 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 933d4e7

Please sign in to comment.