aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py2/tests/test_layout.py
diff options
context:
space:
mode:
authornkozlovskiy <nmk@ydb.tech>2023-09-29 12:24:06 +0300
committernkozlovskiy <nmk@ydb.tech>2023-09-29 12:41:34 +0300
commite0e3e1717e3d33762ce61950504f9637a6e669ed (patch)
treebca3ff6939b10ed60c3d5c12439963a1146b9711 /contrib/python/prompt-toolkit/py2/tests/test_layout.py
parent38f2c5852db84c7b4d83adfcb009eb61541d1ccd (diff)
downloadydb-e0e3e1717e3d33762ce61950504f9637a6e669ed.tar.gz
add ydb deps
Diffstat (limited to 'contrib/python/prompt-toolkit/py2/tests/test_layout.py')
-rw-r--r--contrib/python/prompt-toolkit/py2/tests/test_layout.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/contrib/python/prompt-toolkit/py2/tests/test_layout.py b/contrib/python/prompt-toolkit/py2/tests/test_layout.py
new file mode 100644
index 0000000000..6c9e67b4de
--- /dev/null
+++ b/contrib/python/prompt-toolkit/py2/tests/test_layout.py
@@ -0,0 +1,60 @@
+from __future__ import unicode_literals
+
+from prompt_toolkit.layout.utils import split_lines
+from prompt_toolkit.token import Token
+
+
+def test_split_lines():
+ lines = list(split_lines([(Token.A, 'line1\nline2\nline3')]))
+
+ assert lines == [
+ [(Token.A, 'line1')],
+ [(Token.A, 'line2')],
+ [(Token.A, 'line3')],
+ ]
+
+
+def test_split_lines_2():
+ lines = list(split_lines([
+ (Token.A, 'line1'),
+ (Token.B, 'line2\nline3\nline4')
+ ]))
+
+ assert lines == [
+ [(Token.A, 'line1'), (Token.B, 'line2')],
+ [(Token.B, 'line3')],
+ [(Token.B, 'line4')],
+ ]
+
+
+def test_split_lines_3():
+ " Edge cases: inputs ending with newlines. "
+ # -1-
+ lines = list(split_lines([
+ (Token.A, 'line1\nline2\n')
+ ]))
+
+ assert lines == [
+ [(Token.A, 'line1')],
+ [(Token.A, 'line2')],
+ [(Token.A, '')],
+ ]
+
+ # -2-
+ lines = list(split_lines([
+ (Token.A, '\n'),
+ ]))
+
+ assert lines == [
+ [],
+ [(Token.A, '')],
+ ]
+
+ # -3-
+ lines = list(split_lines([
+ (Token.A, ''),
+ ]))
+
+ assert lines == [
+ [(Token.A, '')],
+ ]