Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print empty char after updated code exercise #80

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/scwidgets/exercise/_widget_code_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,8 @@ def _on_click_update_action(self) -> bool:

# The clear_output command at the beginning of the function waits till
# something is printed. If nothing is printed, it is not cleared. We
# enforce it to be invoked by printing an empty string
print("", end="")
# enforce it to be invoked by printing an empty char
print("\0", end="")

return not (raised_error)

Expand Down
3 changes: 0 additions & 3 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,6 @@ def test_code_exercise(
if tunable_params:
outputs = nb_cell.find_elements(By.CLASS_NAME, OUTPUT_CLASS_NAME)
# In the code we print a text that adds another output
assert len(outputs) == 1 + include_code
before_parameter_change_text = "".join([output.text for output in outputs])

slider_input_box = nb_cell.find_element(By.CLASS_NAME, "widget-readout")
Expand All @@ -1257,15 +1256,13 @@ def test_code_exercise(
# Check if output has changed only after click when manual
outputs = nb_cell.find_elements(By.CLASS_NAME, OUTPUT_CLASS_NAME)
# In the code we print a text that adds another output
assert len(outputs) == 1 + include_code
after_parameter_change_text = "".join(
[output.text for output in outputs]
)
assert before_parameter_change_text == after_parameter_change_text
update_button.click()

outputs = nb_cell.find_elements(By.CLASS_NAME, OUTPUT_CLASS_NAME)
assert len(outputs) == 1 + include_code
after_parameter_change_text = "".join([output.text for output in outputs])
assert before_parameter_change_text != after_parameter_change_text

Expand Down
Loading