aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py2/tests/test_utils.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/prompt-toolkit/py2/tests/test_utils.py
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py2/tests/test_utils.py')
-rw-r--r--contrib/python/prompt-toolkit/py2/tests/test_utils.py78
1 files changed, 39 insertions, 39 deletions
diff --git a/contrib/python/prompt-toolkit/py2/tests/test_utils.py b/contrib/python/prompt-toolkit/py2/tests/test_utils.py
index 1e3d92cda6..b3b56eb738 100644
--- a/contrib/python/prompt-toolkit/py2/tests/test_utils.py
+++ b/contrib/python/prompt-toolkit/py2/tests/test_utils.py
@@ -1,39 +1,39 @@
-from __future__ import unicode_literals
-
-from prompt_toolkit.utils import take_using_weights
-
-import itertools
-
-
-def test_using_weights():
- def take(generator, count):
- return list(itertools.islice(generator, 0, count))
-
- # Check distribution.
- data = take(take_using_weights(['A', 'B', 'C'], [5, 10, 20]), 35)
- assert data.count('A') == 5
- assert data.count('B') == 10
- assert data.count('C') == 20
-
- assert data == [
- 'A', 'B', 'C', 'C', 'B', 'C', 'C', 'A', 'B', 'C', 'C', 'B', 'C',
- 'C', 'A', 'B', 'C', 'C', 'B', 'C', 'C', 'A', 'B', 'C', 'C',
- 'B', 'C', 'C', 'A', 'B', 'C', 'C', 'B', 'C', 'C']
-
- # Another order.
- data = take(take_using_weights(['A', 'B', 'C'], [20, 10, 5]), 35)
- assert data.count('A') == 20
- assert data.count('B') == 10
- assert data.count('C') == 5
-
- # Bigger numbers.
- data = take(take_using_weights(['A', 'B', 'C'], [20, 10, 5]), 70)
- assert data.count('A') == 40
- assert data.count('B') == 20
- assert data.count('C') == 10
-
- # Negative numbers.
- data = take(take_using_weights(['A', 'B', 'C'], [-20, 10, 0]), 70)
- assert data.count('A') == 0
- assert data.count('B') == 70
- assert data.count('C') == 0
+from __future__ import unicode_literals
+
+from prompt_toolkit.utils import take_using_weights
+
+import itertools
+
+
+def test_using_weights():
+ def take(generator, count):
+ return list(itertools.islice(generator, 0, count))
+
+ # Check distribution.
+ data = take(take_using_weights(['A', 'B', 'C'], [5, 10, 20]), 35)
+ assert data.count('A') == 5
+ assert data.count('B') == 10
+ assert data.count('C') == 20
+
+ assert data == [
+ 'A', 'B', 'C', 'C', 'B', 'C', 'C', 'A', 'B', 'C', 'C', 'B', 'C',
+ 'C', 'A', 'B', 'C', 'C', 'B', 'C', 'C', 'A', 'B', 'C', 'C',
+ 'B', 'C', 'C', 'A', 'B', 'C', 'C', 'B', 'C', 'C']
+
+ # Another order.
+ data = take(take_using_weights(['A', 'B', 'C'], [20, 10, 5]), 35)
+ assert data.count('A') == 20
+ assert data.count('B') == 10
+ assert data.count('C') == 5
+
+ # Bigger numbers.
+ data = take(take_using_weights(['A', 'B', 'C'], [20, 10, 5]), 70)
+ assert data.count('A') == 40
+ assert data.count('B') == 20
+ assert data.count('C') == 10
+
+ # Negative numbers.
+ data = take(take_using_weights(['A', 'B', 'C'], [-20, 10, 0]), 70)
+ assert data.count('A') == 0
+ assert data.count('B') == 70
+ assert data.count('C') == 0