File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ # ---
2+ # jupyter:
3+ # jupytext:
4+ # cell_metadata_filter: -all
5+ # text_representation:
6+ # extension: .py
7+ # format_name: light
8+ # format_version: '1.5'
9+ # jupytext_version: 1.15.0
10+ # kernelspec:
11+ # display_name: Python 3 (ipykernel)
12+ # language: python
13+ # name: python3
14+ # ---
15+
16+ # +
17+ import scwidgets
18+ from scwidgets .code import CodeInput
19+
20+ # -
21+
22+ scwidgets .get_css_style ()
23+
24+ # Test 1:
25+ # -------
26+ # Test if CodeInput traits are updading the widget view
27+
28+
29+ # +
30+ def foo ():
31+ return "init"
32+
33+
34+ ci = CodeInput (foo )
35+ ci
36+ # -
37+
38+ ci .function_body = """return 'change'"""
Original file line number Diff line number Diff line change @@ -67,6 +67,12 @@ def test_get_code(self):
6767 ):
6868 CodeInput .get_code (lambda x : x )
6969
70+ def test_invalid_code_theme_raises_error (self ):
71+ with pytest .raises (
72+ ValueError , match = r"Given code_theme 'invalid_theme' invalid.*"
73+ ):
74+ CodeInput (TestCodeInput .mock_function_1 , code_theme = "invalid_theme" )
75+
7076
7177def get_code_exercise (
7278 checks : List [Check ],
Original file line number Diff line number Diff line change @@ -249,6 +249,23 @@ def test_privacy_policy(selenium_driver):
249249 ).click ()
250250
251251
252+ def test_scwidgets_code_input (selenium_driver ):
253+ """
254+ Tests the widget of the module code
255+
256+ :param selenium_driver: see conftest.py
257+ """
258+ driver = selenium_driver ("tests/notebooks/widget_scwidgets_code_input.ipynb" )
259+
260+ nb_cells = NotebookCellList (driver )
261+ # Test 1:
262+ # -------
263+
264+ # Tests if change in function_body changed the widget view
265+ code_input_lines = nb_cells [2 ].find_elements (By .CLASS_NAME , CODE_MIRROR_CLASS_NAME )
266+ assert "return 'change'" in code_input_lines [- 1 ].text
267+
268+
252269class TestExerciseWidgets :
253270 prefix = "pytest"
254271
You can’t perform that action at this time.
0 commit comments