Skip to content

Commit

Permalink
Only mount if container is mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Dec 26, 2024
1 parent 9a6e615 commit 1612722
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,19 @@ async def test_image_step(example_code, image_path: Path):
async with app.run_test() as pilot:
# Initial state should be ImageStep
assert isinstance(app.current_chapter.current_step, ImageStep)
assert app.current_chapter.image_display.visible
assert app.current_chapter.image_container.visible
assert not app.current_chapter.code_display.visible

# Move to next step (Code Step)
await pilot.press("down")
assert isinstance(app.current_chapter.current_step, Step)
assert not app.current_chapter.image_display.visible
assert not app.current_chapter.image_container.visible
assert app.current_chapter.code_display.visible

# Move back to ImageStep
await pilot.press("up")
assert isinstance(app.current_chapter.current_step, ImageStep)
assert app.current_chapter.image_display.visible
assert app.current_chapter.image_container.visible
assert not app.current_chapter.code_display.visible


Expand All @@ -203,12 +203,12 @@ async def test_toggle_dim_image_step(example_code, image_path: Path):

async with app.run_test() as pilot:
# Initial state should be ImageStep
assert app.current_chapter.image_display.visible
assert app.current_chapter.image_container.visible
assert not app.current_chapter.code_display.visible

# Press toggle_dim key
await pilot.press("d")

# Ensure toggle_dim didn't affect ImageStep and code display is still not visible
assert app.current_chapter.image_display.visible
assert app.current_chapter.image_container.visible
assert not app.current_chapter.code_display.visible
3 changes: 2 additions & 1 deletion tuitorial/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def update_display(self) -> None:
for widget in self.image_container.walk_children():
widget.remove()
image_widget = Image(step.image_path)
self.image_container.mount(image_widget)
if self.image_container.is_mounted:
self.image_container.mount(image_widget)

self.description.update(
f"Step {self.current_index + 1}/{len(self.steps)}\n{step.description}",
Expand Down

0 comments on commit 1612722

Please sign in to comment.