This might fix a race condition that lead to a `query` raising `NoMatches`, but this is just theoretical.
Regardless, this seems like the way to go.
Generating the selectors to match the clicked widget needs a view of the DOM before the widget is removed from it (or reordered in the DOM etc.)
Make version info static when running in pytest.
I also tried adding in test_snapshots.py:
import textual_paint
textual_paint.__version__ = "snapshot test edition 1"
import textual_paint.__init__ as init
init.__version__ = "snapshot test edition 2"
which seemed to have no effect.
Since I already have special case logic for __version__ in __init__.py,
I'm reasonably happy with this solution.
This was kind of mind-boggling, narrowing it down to dark mode,
and then to dark mode *but not CSS*.
I kept narrowing it down, and looked into how dark mode was implemented,
and finally figured this out.
`app.call_later(app.refresh_css)` in `App.watch_dark` causes a timing issue.
I'm basically doing TDD to snapshot testing!
I'm creating tests that don't pass yet, setting up an expectation
that the app match the given screenshots, which is funny in a nice
"improper hierarchy" sort of way, but it's possible because I do
actually have the app rendering how I want, just only in isolation.
If I run the ascii_only tests by themselves, I can get good results
from them, but running them interwoven with default Unicode-using UI
tests doesn't work yet, since the ASCII-only mode permanently changes
how certain widgets render, for the life of the process, so that's
what I'm applying TDD to: making it toggleable at runtime.
I commented out the Unicode tests, and uncommented the ASCII-only tests,
renamed test_snapshots.ambr to test_snapshots_ascii.ambr,
reverted the changes to test_snapshots.ambr to get the Unicode version,
ran my new merge_ambr.py script to join the sets of snapshots,
then replaced test_snapshots.ambr with test_snapshots_merged.ambr
Finally, I uncommented both sets of tests, and I'm ready to do TDD!