Closed godlygeek closed 7 months ago
Oof, there's more that needs changing here it seems.
Attention: 1 lines
in your changes are missing coverage. Please review.
Comparison is base (
41248ed
) 92.55% compared to head (88fbf58
) 92.89%. Report is 1 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
tests/conftest.py | 75.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
... Huh. The 3 snapshots I needed to regenerate to get them to pass locally passed on Alpine, Ubuntu 22.04, and macOS, but failed in the manylinux and musllinux containers. What the heck? âšī¸
Ah - those jobs are testing with CPython 3.7, which Textual dropped support for in 0.44...
OK, I think we need to skip these 3 snapshot tests for Python 3.7, then.
Hey đ
Textual snapshot tests will fail if there is a mismatch in the escape codes Textual writes to the terminal. However, different escape sequences can result in the same visual output. A failing snapshot test does not always mean there is a visual difference, it's more of a nudge to double check things, because different escape sequences have been produced.
In the case of the TextArea, we modified how it renders, which will result in some failing tests.
As for the artefacts you see in the diff, I think that's just down to how the browser is rendering the SVG. We actually overlay the two SVGs and the diff is done via CSS, so I think it's just a rendering anomaly at the browser level đ
For the TextArea
changes, if you want to retain the exact same behaviour as before you can simply substitute calls to the TextArea
constructor with TextArea.code_editor
, which is a convenience constructor we added which retains the old defaults (wrapping disabled, syntax highlighting enabled, etc.). If it's not your intention to retain the old behaviour entirely, disregard this paragraph!
different escape sequences have been produced.
In the case of the TextArea, we modified how it renders, which will result in some failing tests.
Fair enough, that makes sense.
As for the artefacts you see in the diff, I think that's just down to how the browser is rendering the SVG. We actually overlay the two SVGs and the diff is done via CSS, so I think it's just a rendering anomaly at the browser level đ
Sounds plausible. I was thinking some characters might have been aligned a few pixels off in the SVG from where they were in a previous version. Either way, I agree that it doesn't seem like anything to worry about.
What I'm much more curious about is why switching from DEFAULT_CSS
to CSS_PATH
fixed some tests that were failing! I know there's some subtle differences between how DEFAULT_CSS
is applied versus how CSS in a file is applied. I know DEFAULT_CSS
is scoped to the widget and its children by default while CSS_PATH
isn't... But I don't think that accounts for the differences, since the widget with the DEFAULT_CSS
was the App
, and so every other widget is one of its descendants...
For the
TextArea
changes, if you want to retain the exact same behaviour as before you can simply substitute calls to theTextArea
constructor withTextArea.code_editor
, which is a convenience constructor we added which retains the old defaults
That was actually a bit uglier to do, since I don't want to drop support for Textual < 0.48 just yet: we'd need to special case on the existence or non-existence of that attribute. I started off writing getattr(TextArea, "code_editor", TextArea)(...)
but that seemed arcane, and it seemed clearer just to set soft_wrap = False
directly (knowing that attribute would just be ignored in old versions).
the old defaults (wrapping disabled, syntax highlighting enabled, etc.)
I didn't notice that there were more differences between the new defaults and the ones set by code_editor
than just soft wrapping, but it turns out we're getting them all right anyway. We're already setting a theme and disabling line numbers and disabling focusing entirely (via can_focus = False
), and that seems to be the sum total of the differences.
Textual 0.48 makes several changes to the
TextArea
that we need to adapt toDEFAULT_CSS
to using a CSS file (I'm not entirely sure why, but some of our CSS rules weren't being applied, and just moving them into a CSS file was enough to fix that. I know the priority of rules inDEFAULT_CSS
is funny...)Even with the SVG, outside of the "show differences" mode I can't see the difference between the old: and the new: