diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/prompt-toolkit/py3/tests/test_layout.py | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/tests/test_layout.py')
-rw-r--r-- | contrib/python/prompt-toolkit/py3/tests/test_layout.py | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/contrib/python/prompt-toolkit/py3/tests/test_layout.py b/contrib/python/prompt-toolkit/py3/tests/test_layout.py index 8a0826d33bf..466be688679 100644 --- a/contrib/python/prompt-toolkit/py3/tests/test_layout.py +++ b/contrib/python/prompt-toolkit/py3/tests/test_layout.py @@ -1,51 +1,51 @@ -import pytest - -from prompt_toolkit.layout import InvalidLayoutError, Layout -from prompt_toolkit.layout.containers import HSplit, VSplit, Window -from prompt_toolkit.layout.controls import BufferControl - - -def test_layout_class(): - c1 = BufferControl() - c2 = BufferControl() - c3 = BufferControl() - win1 = Window(content=c1) - win2 = Window(content=c2) - win3 = Window(content=c3) - - layout = Layout(container=VSplit([HSplit([win1, win2]), win3])) - - # Listing of windows/controls. - assert list(layout.find_all_windows()) == [win1, win2, win3] - assert list(layout.find_all_controls()) == [c1, c2, c3] - - # Focusing something. - layout.focus(c1) - assert layout.has_focus(c1) - assert layout.has_focus(win1) - assert layout.current_control == c1 - assert layout.previous_control == c1 - - layout.focus(c2) - assert layout.has_focus(c2) - assert layout.has_focus(win2) - assert layout.current_control == c2 - assert layout.previous_control == c1 - - layout.focus(win3) - assert layout.has_focus(c3) - assert layout.has_focus(win3) - assert layout.current_control == c3 - assert layout.previous_control == c2 - - # Pop focus. This should focus the previous control again. - layout.focus_last() - assert layout.has_focus(c2) - assert layout.has_focus(win2) - assert layout.current_control == c2 - assert layout.previous_control == c1 - - -def test_create_invalid_layout(): - with pytest.raises(InvalidLayoutError): - Layout(HSplit([])) +import pytest + +from prompt_toolkit.layout import InvalidLayoutError, Layout +from prompt_toolkit.layout.containers import HSplit, VSplit, Window +from prompt_toolkit.layout.controls import BufferControl + + +def test_layout_class(): + c1 = BufferControl() + c2 = BufferControl() + c3 = BufferControl() + win1 = Window(content=c1) + win2 = Window(content=c2) + win3 = Window(content=c3) + + layout = Layout(container=VSplit([HSplit([win1, win2]), win3])) + + # Listing of windows/controls. + assert list(layout.find_all_windows()) == [win1, win2, win3] + assert list(layout.find_all_controls()) == [c1, c2, c3] + + # Focusing something. + layout.focus(c1) + assert layout.has_focus(c1) + assert layout.has_focus(win1) + assert layout.current_control == c1 + assert layout.previous_control == c1 + + layout.focus(c2) + assert layout.has_focus(c2) + assert layout.has_focus(win2) + assert layout.current_control == c2 + assert layout.previous_control == c1 + + layout.focus(win3) + assert layout.has_focus(c3) + assert layout.has_focus(win3) + assert layout.current_control == c3 + assert layout.previous_control == c2 + + # Pop focus. This should focus the previous control again. + layout.focus_last() + assert layout.has_focus(c2) + assert layout.has_focus(win2) + assert layout.current_control == c2 + assert layout.previous_control == c1 + + +def test_create_invalid_layout(): + with pytest.raises(InvalidLayoutError): + Layout(HSplit([])) |