Commit Graph

3546 Commits

Author SHA1 Message Date
Dave Pearson
87e18de605 Move the assert on key records into all_recorded
While what I had worked, asserting on a boolean return from that method
ended up masking what had gone wrong. This way we get to see the fail
and *why* it failed.
2022-12-13 21:56:43 +00:00
Dave Pearson
5330d2a425 DRY the checking of the recorded keystrokes 2022-12-13 18:40:00 +00:00
Dave Pearson
c6981964a7 Fix a typo 2022-12-13 18:23:44 +00:00
Dave Pearson
c68dae6ad7 Try and coax older Pythons into being happy with list[...]
I think?
2022-12-13 18:19:20 +00:00
Dave Pearson
cdca7dc2dd Revamp the binding inheritance unit tests
The tests are getting a little involved, and aim to tell an important story
about how the binding inheritance works, currently causes problems, and
should eventually work. As such I feel it's time to tidy things up a bit,
reduce some of the copy/paste going on, and comment heavily so I don't lose
my place and thinking, not to mention hopefully help someone else reading
make sense of the tests.
2022-12-13 18:10:40 +00:00
Dave Pearson
67cb7f1121 Revert d92c252ea6
For now anyway. I suspect this definition if is_scrollable will become moot
soon (ideally there would never be an is_scrollable property at all, ever,
as inheritance should ideally dictate this if the changes that are planned
go the way as planned -- a property that tells you something about
provenance when the inheritance tree tells you that is some bad OO smell)
but I want to get the tests set up as their own PR first and *then* work on
the fix.
2022-12-13 17:03:28 +00:00
Dave Pearson
3f225469a5 Remove xfail on non-inherit-no-BINDINGS test
This now is fine thanks to #1352 fixing #1351.
2022-12-13 16:59:05 +00:00
Dave Pearson
1158bff4d2 Merge branch 'main' into bug/1342/inherited-movement-keys 2022-12-13 16:56:34 +00:00
Will McGugan
a8c3018ba3 Merge pull request #1352 from Textualize/fix-1351
Fix binding merging when binding inheritance is set to `False`.
2022-12-13 16:37:15 +00:00
Rodrigo Girão Serrão
e9a5995c47 Update changelog. 2022-12-13 16:19:47 +00:00
Rodrigo Girão Serrão
f5dbdc9ee1 Merge branch 'main' into fix-1351 2022-12-13 16:18:39 +00:00
Rodrigo Girão Serrão
94c05aa876 Fix binding merging a la #1336 2022-12-13 16:16:04 +00:00
Rodrigo Girão Serrão
6d480056e5 Add a test for binding merging. 2022-12-13 16:15:28 +00:00
Will McGugan
9acdd70e36 Merge pull request #1350 from Textualize/fix-decimate
move refresh
2022-12-13 15:54:06 +00:00
Rodrigo Girão Serrão
d49477ce5a Merge pull request #1336 from Textualize/fix-1335
Fix default CSS retrieval from widgets with no `DEFAULT_CSS` that inherit from widgets that do have `DEFAULT_CSS`
2022-12-13 15:43:07 +00:00
Dave Pearson
e8c87ced33 Add test for focused widget, no inherit, empty BINDINGS
Testing the overlap between #1343 and #1351.
2022-12-13 15:29:13 +00:00
Dave Pearson
0251a4bd57 Add a test for #1351 2022-12-13 15:21:23 +00:00
Rodrigo Girão Serrão
37dec51432 Simplify default css retrieval.
By making use of __dict__ we have a simpler way of determining if the class defines its own default_css which does not involve comparing with the base class's default_css.
2022-12-13 15:06:47 +00:00
Dave Pearson
e74dbab8cf Fix test of alpha keys so they match how we test movement keys 2022-12-13 12:44:25 +00:00
Dave Pearson
2b2f19381b Fix test of alpha keys so they match how we test movement keys 2022-12-13 12:42:33 +00:00
Dave Pearson
09fd71e8f6 Improve the name of one of the tests
Just to make it a bit more clear what's going on and why. There's a fair bit
goes into each of these tests and this module is in danger of getting quite
messy. I may revisit the layout at some point just to make it all a lot more
readable.
2022-12-13 12:28:23 +00:00
Dave Pearson
a44c0f5d7f Add a test for widget bindings with binding inheritance turned off 2022-12-13 11:32:09 +00:00
Dave Pearson
a01ab65264 Add a module docstring to the binding inheritance tests
I feel that, for now anyway, these needs a bit more background for the
reader.
2022-12-13 10:48:28 +00:00
Dave Pearson
fc4ee698ca Remove redundant app check in test relating to a widget
It made sense to do this extra step as I was finding my way with these
tests, but I don't think it's necessary now.
2022-12-13 10:44:55 +00:00
Dave Pearson
f0eb284edb Correct a test description 2022-12-13 10:42:48 +00:00
Will McGugan
966c4d0db9 move refresh 2022-12-13 10:35:22 +00:00
Dave Pearson
4554904f2b Sort the two key lists before comparing
We're coming from a dictionary for one of them, so let's give ourselves a
fighting chance here.
2022-12-13 10:27:33 +00:00
Dave Pearson
3bb7a99a0a Rework the basic Screen binding test
Rather than test that it has zero bindings (although that is a legitimate
test too), test for the thing we're really concerned about here: that it
doesn't have movement keys. That's what this is all about.
2022-12-13 10:25:43 +00:00
Dave Pearson
4a1a78819e Correct a copy/paste-o in the key test
Not that this made a change to its passing/failing state right at the moment
-- it's going to fail anyway -- but it kinda needs to be in its proper "this
should pass" state.
2022-12-13 10:18:46 +00:00
Dave Pearson
e75f784b2c Add a test for a screen binding movement, wrapping a focusable widget
This is the heart of the issue introduced by
b48a1402b8
and which is being investigated in
https://github.com/Textualize/textual/issues/1343 -- the child widget can be
focused, but (as far as the author of the code is concerned) it has no
bindings. Bindings for movement-oriented keys exist on the screen which
composes up the widget into it. Up until 0.5.0 this worked just fine. As of
0.6.0, because binding inheritance was introduced, the bindings for movement
that live at the `Widget` level cause the widget that has no bindings to
appear to have bindings.

While this can potentially be worked around with the use of
inherit_bindings, this isn't a very satisfying solution and also breaks the
rule of least astonishment.

This test is going to be key to all of this. This is the test that should be
made to work without breaking any of the other currently-passing tests.
2022-12-13 10:12:16 +00:00
Dave Pearson
06e45c709e Add an alpha binding and key press to the focused widget test
This is going to become important in the next test I'm intending to add, so
it feels sensible to mirror the intended addition here too.
2022-12-13 10:02:44 +00:00
Dave Pearson
4955a28ab1 Keep black happy (again)
Need to sort out the pre-commit hooks for this machine
2022-12-13 09:48:09 +00:00
Dave Pearson
c52ea0bdf2 Add a test for a focused child widget with its own bindings 2022-12-13 09:46:27 +00:00
Will McGugan
338d74cd46 Merge pull request #1339 from davep/event-props
Add some missing widget event attributes
2022-12-13 09:26:04 +00:00
Dave Pearson
d92c252ea6 Make it clear, in the code, that all containers are considered scrollable
The code is exactly the same between is_container and is_scrollable, and the
intent (confirmed in
https://github.com/Textualize/textual/issues/1343#issuecomment-1347989752)
is that the latter is intended to be overridden in some circumstances (so
far only in `ScrollView`). As such I feel it better conveys intent and
reduces the changes of mismatched future changes if is_scrollable is defined
in respect to is_container.

The only possible reason I can think of is if there's a measurable
performance win here. Applying Knuth for the moment, at least for the scope
of this PR. I strongly suspect this is one of the 97% rather than one of the
3% and for the purposes of moving stuff around (which I may be doing as I
explore this) I believe this makes it easier to follow and to think about.
2022-12-13 09:13:00 +00:00
Will McGugan
df041d002a fix path 2022-12-13 08:48:39 +00:00
Dave Pearson
b48acc0bd5 Update the movement binding tests to use all movement keys
Rather than just test a single specific movement key (in this case "up"), go
with all the affected keys. The cost to doing so is zero and it means we get
a full coverage of testing for all the keys that have become a problem with
0.6.0.
2022-12-13 08:27:22 +00:00
Dave Pearson
751042f9d7 Add a test for actions being fired from bound keys
Do this with a focus on detecting a bound alpha key, and a bound movement key
2022-12-12 21:53:23 +00:00
Dave Pearson
f32937641a Add binding inheritance tests for Static widgets 2022-12-12 21:04:56 +00:00
Dave Pearson
6b77e73558 Start unit tests for live key bindings plus inheriting
Up until now there doesn't seem to have been any unit tests aimed squarely
at setting up bindings, as part of a running application, which are only
about testing the bindings. As such there was no way of slotting in tests
for how inheritance of bindings works.

This starts that process with a view to testing how inheriting
likely *should* work.

See #1343 for some background to this.
2022-12-12 20:49:19 +00:00
Dave Pearson
24d479f6d5 Keep black happy 2022-12-11 21:54:37 +00:00
Dave Pearson
9404af0080 Add attribute documentation to ListView.Selected 2022-12-11 21:48:23 +00:00
Dave Pearson
bed2d2ae67 Add attribute documentation to ListView.Highlighted 2022-12-11 21:47:39 +00:00
Dave Pearson
7394949fa9 Add attribute documentation to Button.Pressed 2022-12-11 21:46:13 +00:00
Dave Pearson
25a24fc3e6 Add attribute documentation to Tree.NodeCollapsed 2022-12-11 21:45:31 +00:00
Dave Pearson
1e1289f5e2 Add attribute documentation to Tree.NodeExpanded 2022-12-11 21:45:19 +00:00
Dave Pearson
23e21d7cc0 Add attribute documentation to Tree.NodeSelected 2022-12-11 21:45:02 +00:00
Dave Pearson
058921110e Clean up trailing whitespace 2022-12-11 21:44:41 +00:00
Dave Pearson
420e261dab Add attribute documentation to Input.Submitted 2022-12-11 21:40:37 +00:00
Dave Pearson
9bd2542f39 Add attribute documentation to Input.Changed 2022-12-11 21:38:07 +00:00