diff --git a/src/ansys/fluent/core/services/datamodel_tui.py b/src/ansys/fluent/core/services/datamodel_tui.py index c22285473fb..979d8192207 100644 --- a/src/ansys/fluent/core/services/datamodel_tui.py +++ b/src/ansys/fluent/core/services/datamodel_tui.py @@ -330,9 +330,14 @@ def __dir__(self) -> list[str]: for x in PyMenu( self._service, self._version, self._mode, self._path ).get_child_names() + if x != "exit" ] def __getattribute__(self, name) -> Any: + if name == "exit" and not self._path: + raise AttributeError( + f"'{self.__class__.__name__}' object has no attribute 'exit'" + ) try: attr = super().__getattribute__(name) if isinstance(attr, TUIMethod): diff --git a/tests/test_tui_api.py b/tests/test_tui_api.py index 9d01c3a4574..193f85c00cd 100644 --- a/tests/test_tui_api.py +++ b/tests/test_tui_api.py @@ -50,3 +50,21 @@ def test_api_upgrade_message(new_solver_session): ) else: assert s.split("\n")[-2].split("(")[0] == r".file.read_case" + + +def test_exit_not_in_meshing_tui(new_meshing_session): + meshing = new_meshing_session + + assert "exit" not in dir(meshing.tui) + + with pytest.raises(AttributeError): + meshing.tui.exit() + + +def test_exit_not_in_solver_tui(new_solver_session): + solver = new_solver_session + + assert "exit" not in dir(solver.tui) + + with pytest.raises(AttributeError): + solver.tui.exit()