From 899915073c76564c82128aca292067e9d5e67606 Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Thu, 19 Dec 2024 17:03:52 +0100 Subject: [PATCH] Add `parameters_panel` property to `CodeExercise` (#107) --- src/scwidgets/exercise/_widget_code_exercise.py | 8 ++++++++ tests/test_code.py | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/scwidgets/exercise/_widget_code_exercise.py b/src/scwidgets/exercise/_widget_code_exercise.py index c8690c6..74d8f4f 100644 --- a/src/scwidgets/exercise/_widget_code_exercise.py +++ b/src/scwidgets/exercise/_widget_code_exercise.py @@ -553,6 +553,14 @@ def answer(self, answer: dict): if self._load_button is not None: self._load_button.observe_widgets() + @property + def parameters_panel(self) -> Union[ParametersPanel, None]: + """ + :return: The parametergs panel widget. + """ + + return self._parameters_panel + @property def panel_parameters(self) -> Dict[str, Check.FunInParamT]: """ diff --git a/tests/test_code.py b/tests/test_code.py index 9aa8183..433115f 100644 --- a/tests/test_code.py +++ b/tests/test_code.py @@ -231,6 +231,17 @@ def update_print(code_ex: CodeExercise): class TestCodeExercise: + @pytest.mark.parametrize( + "code_ex", + [ + get_code_exercise( + [single_param_check(use_fingerprint=False, failing=False, buggy=False)], + ) + ], + ) + def test_parameters_panel(self, code_ex): + assert code_ex.parameters_panel.parameters == code_ex.parameters + @pytest.mark.parametrize( "code_ex", [