pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.54k stars 197 forks source link

Support for latest urwid #1330

Closed fabaff closed 4 months ago

fabaff commented 5 months ago

Describe the bug A test (test_convert_to_date) fails. I guess that DeprecationWarnings are already on the radar.

To Reproduce Run pytest with the latest urwid installed.

============================= test session starts ==============================
platform linux -- Python 3.11.7, pytest-7.4.3, pluggy-1.3.0
rootdir: /build/source
plugins: hypothesis-6.91.0
collected 315 items / 5 deselected / 310 selected                              

tests/backend_test.py ..............................                     [  9%]
[...]
tests/vtimezone_test.py ..                                               [ 96%]
tests/ui/test_calendarwidget.py .....                                    [ 98%]
tests/ui/test_editor.py ...F                                             [ 99%]
tests/ui/test_widgets.py .                                               [100%]

=================================== FAILURES ===================================
_____________________________ test_convert_to_date _____________________________

    def test_convert_to_date():
        """test for the issue in #666"""
        editor = StartEndEditor(
            BERLIN.localize(dt.datetime(2017, 10, 2, 13)),
            BERLIN.localize(dt.datetime(2017, 10, 4, 18)),
            conf=CONF
        )
>       canvas = editor.render((50, ), True)

tests/ui/test_editor.py:106: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/karvk8vcyr86y5mqd1xb5q6ym8vw6yby-python3.11-urwid-2.4.3/lib/python3.11/site-packages/urwid/widget/widget.py:112: in cached_render
[...]
    validate_size(self, size, canv)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

widget = <Padding selectable fixed/flow widget <CalendarPopUp selectable flow widget <ValidatedEdit selectable flow widget>> right=1 width=11>
size = (10,)
canv = <CompositeCanvas finalized=False cols=11 rows=1 cursor=(10, 0) children=(<CompositeCanvas finalized=True cols=11 rows=... at 0x7FFFE6818C10>) at 0x7FFFE6818D10>) at 0x7FFFE6818F90>) at 0x7FFFE6819190>) at 0x7FFFE68193D0>) at 0x7FFFE6819610>

    def validate_size(widget, size, canv):
        """
        Raise a WidgetError if a canv does not match size.
        """
        if (size and size[1:] != (0,) and size[0] != canv.cols()) or (len(size) > 1 and size[1] != canv.rows()):
>           raise WidgetError(
                f"Widget {widget!r} rendered ({canv.cols():d} x {canv.rows():d}) canvas when passed size {size!r}!"
            )
E           urwid.widget.widget.WidgetError: Widget <Padding selectable fixed/flow widget <CalendarPopUp selectable flow widget <ValidatedEdit selectable flow widget>> right=1 width=11> rendered (11 x 1) canvas when passed size (10,)!

/nix/store/karvk8vcyr86y5mqd1xb5q6ym8vw6yby-python3.11-urwid-2.4.3/lib/python3.11/site-packages/urwid/widget/widget.py:92: WidgetError
=============================== warnings summary ===============================
tests/backend_test.py:5
  /build/source/tests/backend_test.py:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources
[...]
  /build/source/khal/ui/widgets.py:294: PendingDeprecationWarning: only for backwards compatibility.You may also use the new standard container property `focus_position` to get the focus.
    self.set_focus(i)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/ui/test_editor.py::test_convert_to_date - urwid.widget.widget.WidgetError: Widget <Padding selectable fixed/flow widg...
= 1 failed, 306 passed, 5 deselected, 1 xfailed, 2 xpassed, 178 warnings in 3.92s =

Expected behavior Tests to pass.

OS, version, khal version and how you installed it:

Additional context Only an issue for distributions, will probably not affect users who are working with venvs.

geier commented 4 months ago

Thank you for the bug report!

Should be fixed with v0.11.3 and also in master.