diff --git a/tests/test_structs.py b/tests/test_structs.py index 058fcdf2..c6addd6d 100644 --- a/tests/test_structs.py +++ b/tests/test_structs.py @@ -44,6 +44,31 @@ def test_modelobj_line_label_setter(): assert obj.line_label == "[1, 2, 3]: " +def test_modelobj_print_line(): + class DummyModelObj(ModelObj): + def gen_string(self) -> str: + return "dummy_object" + + obj = DummyModelObj() + + # Test base case with no line label and no comment + assert obj.print_line() == " dummy_object" + + # Test with line label only + obj.line_label = 1 + assert obj.print_line() == " 1 dummy_object" + + # Test with comment only + obj._line_label = None # reset line_label + obj.comment = "# test comment" + assert obj.print_line() == " dummy_object # test comment" + + # Test with both line label and comment + obj.line_label = 1 + obj.comment = "# test comment" + assert obj.print_line() == " 1 dummy_object # test comment" + + def test_action_print_line(): action = Action(action_type="simulate", action_args={"method": "ode", "t_end": 10}) # Basic print_line without comment or label