Skip to content

Commit

Permalink
Debugging for remove_tab test flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Oct 19, 2023
1 parent c837abe commit 6d06d2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Test with pytest
run: |
source $VENV
pytest tests -v --cov=./src/textual --cov-report=xml:./coverage.xml --cov-report term-missing
pytest tests -k test_remove_tab
- name: Upload snapshot report
if: always()
uses: actions/upload-artifact@v3
Expand Down
10 changes: 8 additions & 2 deletions src/textual/widgets/_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def render(self) -> RenderResult:
background_style=Style.from_color(bar_style.bgcolor),
)

def _on_mount(self, event: events.Mount) -> None:
print("Underline mounted")

def _on_click(self, event: events.Click):
"""Catch clicks, so that the underline can activate the tabs."""
event.stop()
Expand Down Expand Up @@ -487,6 +490,7 @@ def remove_tab(self, tab_or_id: Tab | str | None) -> AwaitComplete:
Returns:
An optionally awaitable object that waits for the tab to be removed.
"""
print("Top of remove_tab")
if not tab_or_id:
return AwaitComplete(self.app._remove_nodes([], None)())

Expand All @@ -513,7 +517,6 @@ async def do_remove() -> None:
self.active = next_tab.id
next_tab.add_class("-active")

self.call_after_refresh(self._highlight_active, animate=True)
highlight_updated.set()

async def wait_for_highlight_update() -> None:
Expand All @@ -537,6 +540,7 @@ def active_tab(self) -> Tab | None:

def _on_mount(self, _: Mount) -> None:
"""Make the first tab active."""
print("Top of on_mount")
if self._first_active is not None:
self.active = self._first_active
if not self.active:
Expand All @@ -557,15 +561,17 @@ def compose(self) -> ComposeResult:
def watch_active(self, previously_active: str, active: str) -> None:
"""Handle a change to the active tab."""
if active:
print("Top of watch active. (inside if active)")
try:
active_tab = self.query_one(f"#tabs-list > #{active}", Tab)
except NoMatches:
return
self.query("#tabs-list > Tab.-active").remove_class("-active")
active_tab.add_class("-active")
self.call_later(self._highlight_active, animate=previously_active != "")
self._highlight_active(animate=previously_active != "")
self.post_message(self.TabActivated(self, active_tab))
else:
print("Top of watch active. (not active branch)")
underline = self.query_one(Underline)
underline.highlight_start = 0
underline.highlight_end = 0
Expand Down

0 comments on commit 6d06d2a

Please sign in to comment.