Commit Graph

3574 Commits

Author SHA1 Message Date
Dave Pearson
32d3fc054a Revert to a deliberate priority binding lookup fail
Just for the moment; just to see if I can get this to fail normally in CI.
2022-12-15 13:47:17 +00:00
Dave Pearson
0e89e88943 Hail Mary change to how I reverse the binding chain
This seems highly unlikely, but as an experiment...
2022-12-15 13:31:24 +00:00
Dave Pearson
b196d8cd2e Revert experimental backing out of recent changes
Didn't make a difference. CI on GitHub is still acting differently.
2022-12-15 13:29:27 +00:00
Dave Pearson
76a22d81d4 Eliminating changes
This is the one biggish change between the last working test run in GitHub,
and now. Tests are still running locally fine, an on GitHub, in the last
run, I had one job pass and another fail, both on the same OS, just 3.10
passed and 3.9 failed. The problem still to do with (as far as I can tell)
messages inside Textual and some sort of async issue.

So let's try this.
2022-12-15 13:25:05 +00:00
Dave Pearson
938cd3bd1d Namespace the recording actions
Wondering if this is the issue with why the tests have stopped working in
GitHub; but also not *really* confused as to why they were working in the
first place.
2022-12-15 13:17:16 +00:00
Dave Pearson
2f77bab409 Extra long pause test
This code is running just finally locally in tests, but is failing with:

RuntimeError: Task <Task pending name='Task-279' coro=<MessagePump._process_messages() running at /home/runner/work/textual/textual/src/textual/message_pump.py:314>> got Future <Future pending> attached to a different loop

in GitHub Actions. Pretty sure I saw this before, which made me add the
pause in the first place. Given this seems to just be affecting the last
test, from what I can tell, let's make the pause longer to see if that
helps.

I hate chasing action issues...
2022-12-15 12:57:14 +00:00
Dave Pearson
ad7c2e6c4d Round off the priority clash test and un-xfail it
Also add in a test for when there is no priority anywhere. This is still a
priority level that needs testing, it just isn't a priority.
2022-12-15 12:47:46 +00:00
Dave Pearson
90ecf4e37b If checking for a priority binding, go App down
If not, go lowest level up.
2022-12-15 12:46:48 +00:00
Dave Pearson
618db503b9 Add tests for competing bindings an priority permutations
This is set to xfail at the moment because the tested result is what I think
should be the result, but what happens now isn't that. Need to check with
Will to see what he thinks the correct resolution is here.
2022-12-15 12:16:27 +00:00
Dave Pearson
50df082479 Keep black happy 2022-12-15 12:16:16 +00:00
Dave Pearson
8ff9af581c Test rationale comment update 2022-12-15 09:10:00 +00:00
Dave Pearson
4a78283574 Update the binding inheritance tests to reflect the emerging changes
I feel some more will be needed, but this is all of the basics, hitting all
of the important points that relate to #1343. More importantly all of the
xfails are now removed.
2022-12-14 20:59:57 +00:00
Dave Pearson
bb5dd97634 Make bindings on App and child classes priority by default
As requested by @willmcgugan while discussing #1343.
2022-12-14 20:59:35 +00:00
Dave Pearson
f1b5af2c71 Make bindings on Screen and child classes priority by default
As requested by @willmcgugan while discussing #1343.
2022-12-14 20:58:19 +00:00
Dave Pearson
cb0f8d2664 Add support for a PRIORITY_BINDINGS classvar
This works in conjunction with BINDINGS. If a widget has BINDINGS, and if
any of those bindings have a priority that isn't True or False, the value of
PRIORITY_BINDINGS will be used (or the value from one of the parent classes,
if there are any, will be used if it isn't set on the current class).

See #1343.
2022-12-14 20:57:54 +00:00
Dave Pearson
96a7701de1 Add support for a default priority for Bindings
This commit changes things slightly so that the priority of a binding is an
three-state: True, False or None. True and False are firm choices that
nothing else should override. None says "fall back to whatever default is up
for grabs".

The commit also then adds support for a default priority and, when building
a binding, it uses that if the binding has a priority of None.

See #1343.
2022-12-14 20:52:09 +00:00
Dave Pearson
e300bf2d71 Strip the keys before turning them into bindings 2022-12-14 17:35:11 +00:00
Dave Pearson
dcad134acd Add a (currently) breaking test for spaces within a key list
At the moment at least, we don't allow binding on " ", we bind on "space".
Meanwhile, tidy folk may try and bind in "a, b, c, d" as opposed to trying
to bind on "a,b,c,d". I feel we should allow for that.

This test, which breaks at the moment, should be satisfied.
2022-12-14 17:29:47 +00:00
Dave Pearson
bf3c2dd060 Add a docstring to Bindings.__init__ 2022-12-14 17:13:44 +00:00
Dave Pearson
af5ef6c1a4 Merge branch 'main' into bug/1342/inherited-movement-keys 2022-12-14 16:21:57 +00:00
Dave Pearson
b2ac3f66c8 Merge pull request #1363 from davep/prune-unused-mounterror-import
Remove unused import of MounrError in app.py
2022-12-14 16:00:21 +00:00
Dave Pearson
e9de8a2d44 Remove unused import of MounrError in app.py
Noticed while passing by.
2022-12-14 15:29:25 +00:00
Dave Pearson
7c37c9b0f3 Rename the binding universal argument to priority
As per https://github.com/Textualize/textual/issues/1343#issuecomment-1351087237
2022-12-14 15:21:03 +00:00
Dave Pearson
9cec7bd840 Add a docstring to the Binding dataclass 2022-12-14 15:04:33 +00:00
Dave Pearson
d9e73b82f5 Be less explicit about checking for movement keys, check for any keys
See https://github.com/Textualize/textual/pull/1346#discussion_r1048330186
2022-12-14 11:12:46 +00:00
Dave Pearson
d353188c24 Correct a typo 2022-12-14 10:59:17 +00:00
Dave Pearson
5859437040 Run black over the tests 2022-12-14 10:58:09 +00:00
Dave Pearson
ca9c3b43dd Add the likely "final boss" test for the binding issue 2022-12-13 21:58:09 +00:00
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