Skip to content

Fix incorrect type cast in vterm (apply_mapping should return bytes)#545

Merged
penguinolog merged 2 commits into
urwid:masterfrom
penguinolog:test_vterm_check
Apr 25, 2023
Merged

Fix incorrect type cast in vterm (apply_mapping should return bytes)#545
penguinolog merged 2 commits into
urwid:masterfrom
penguinolog:test_vterm_check

Conversation

@penguinolog

@penguinolog penguinolog commented Apr 25, 2023

Copy link
Copy Markdown
Collaborator

Add time.sleep(0.1) to the event loop tests:
in the worst scenario on windows and slow machine
function in parallel thread/async can wait up to 80 milliseconds (tested)
Add type annotations to the vterm and test_vterm to simplify error lookup.

Partial: #544
Partial: #512
Partial: #406

Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment

@penguinolog penguinolog force-pushed the test_vterm_check branch 5 times, most recently from 7e1ea53 to 34a2e06 Compare April 25, 2023 12:34
Comment thread urwid/wimp.py

>>> changes = []
>>> def callback_a(cb, state, user_data):
>>> def callback_a(user_data, cb, state):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wardi looks like incorrect resolve order in Signals.emit: cb is part of *args -> put after user_args and before deprecated user_arg.

Comment thread pyproject.toml
profile = "black"
line_length = 120

[tool.pytest.ini_options]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now preparation only: warnings collected much better, but non-stable event loop tests and fully incompatible test_vterm

Comment thread urwid/widget.py
return canv


class SolidFill(BoxWidget):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

many years deprecated base class

Comment thread urwid/vterm.py
dec_pos = DEC_SPECIAL_CHARS.find(char.decode('cp437'))
if dec_pos >= 0:
self.current = '0'
return str(ALT_DEC_SPECIAL_CHARS[dec_pos])

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect cast, will cause BytesWarning

Comment thread urwid/tests/test_vterm.py
self.expect(' x5a98765')

def test_scrolling_region_simple(self):
# TODO(Aleksei): Issue #544

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 tests which fail on regular basis

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can mark them as flaky or to be skipped so they don't fail unrelated changes, can't we?

Add `time.sleep(0.1)` to the event loop tests:
  in the worst scenario on windows and slow machine
  function in parallel thread/async can wait up to 80 milliseconds (tested)
Add type annotations to the `vterm` and `test_vterm` to simplify error lookup.
* Fix `DeprecationWarning` in doctests & examples
* Add `pytest` configuration in `pyproject.toml` without migration
* `Signals.emit()` rework: stop `user_args` join with `weak_args`

Partial: urwid#544
Partial: urwid#512
Partial: urwid#406
Comment thread urwid/tests/test_event_loops.py Outdated
Comment thread urwid/vterm.py
``command`` is the command to execute inside the terminal,
provided as a list of the command followed by its arguments.
If 'command' is None, the command is the current user's shell.
You can also provide a callable instead of a command, which will be executed in the subprocess.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like you almost aligned this paragraph to a new line width

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed split to increase readability: misread caused incomplete type annotation

* set timer for errors raise to 0: faster raise, faster test done
@penguinolog penguinolog requested a review from wardi April 25, 2023 16:17
@penguinolog penguinolog merged commit 1cc1d63 into urwid:master Apr 25, 2023
@penguinolog penguinolog deleted the test_vterm_check branch September 28, 2023 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants