##// END OF EJS Templates
Silence Warnigns of deprecated functionality tests....
Matthias Bussonnier -
Show More
@@ -77,7 +77,8 b' def test_spaces():'
77 ('\tx', 1),
77 ('\tx', 1),
78 ('\t x', 2),
78 ('\t x', 2),
79 ]
79 ]
80 tt.check_pairs(isp.num_ini_spaces, tests)
80 with pytest.warns(PendingDeprecationWarning):
81 tt.check_pairs(isp.num_ini_spaces, tests)
81
82
82
83
83 def test_remove_comments():
84 def test_remove_comments():
@@ -26,37 +26,93 b' from IPython.utils import text'
26 # Globals
26 # Globals
27 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
28
28
29 def test_columnize():
29
30 @pytest.mark.parametrize(
31 "expected, width, row_first, spread",
32 (
33 (
34 "aaaaa bbbbb ccccc ddddd\n",
35 80,
36 False,
37 False,
38 ),
39 (
40 "aaaaa ccccc\nbbbbb ddddd\n",
41 25,
42 False,
43 False,
44 ),
45 (
46 "aaaaa ccccc\nbbbbb ddddd\n",
47 12,
48 False,
49 False,
50 ),
51 (
52 "aaaaa\nbbbbb\nccccc\nddddd\n",
53 10,
54 False,
55 False,
56 ),
57 (
58 "aaaaa bbbbb ccccc ddddd\n",
59 80,
60 True,
61 False,
62 ),
63 (
64 "aaaaa bbbbb\nccccc ddddd\n",
65 25,
66 True,
67 False,
68 ),
69 (
70 "aaaaa bbbbb\nccccc ddddd\n",
71 12,
72 True,
73 False,
74 ),
75 (
76 "aaaaa\nbbbbb\nccccc\nddddd\n",
77 10,
78 True,
79 False,
80 ),
81 (
82 "aaaaa bbbbb ccccc ddddd\n",
83 40,
84 False,
85 True,
86 ),
87 (
88 "aaaaa ccccc\nbbbbb ddddd\n",
89 20,
90 False,
91 True,
92 ),
93 (
94 "aaaaa ccccc\nbbbbb ddddd\n",
95 12,
96 False,
97 True,
98 ),
99 (
100 "aaaaa\nbbbbb\nccccc\nddddd\n",
101 10,
102 False,
103 True,
104 ),
105 ),
106 )
107 def test_columnize(expected, width, row_first, spread):
30 """Basic columnize tests."""
108 """Basic columnize tests."""
31 size = 5
109 size = 5
32 items = [l*size for l in 'abcd']
110 items = [l*size for l in 'abcd']
33
111 with pytest.warns(PendingDeprecationWarning):
34 out = text.columnize(items, displaywidth=80)
112 out = text.columnize(
35 assert out == "aaaaa bbbbb ccccc ddddd\n"
113 items, displaywidth=width, row_first=row_first, spread=spread
36 out = text.columnize(items, displaywidth=25)
114 )
37 assert out == "aaaaa ccccc\nbbbbb ddddd\n"
115 assert out == expected
38 out = text.columnize(items, displaywidth=12)
39 assert out == "aaaaa ccccc\nbbbbb ddddd\n"
40 out = text.columnize(items, displaywidth=10)
41 assert out == "aaaaa\nbbbbb\nccccc\nddddd\n"
42
43 out = text.columnize(items, row_first=True, displaywidth=80)
44 assert out == "aaaaa bbbbb ccccc ddddd\n"
45 out = text.columnize(items, row_first=True, displaywidth=25)
46 assert out == "aaaaa bbbbb\nccccc ddddd\n"
47 out = text.columnize(items, row_first=True, displaywidth=12)
48 assert out == "aaaaa bbbbb\nccccc ddddd\n"
49 out = text.columnize(items, row_first=True, displaywidth=10)
50 assert out == "aaaaa\nbbbbb\nccccc\nddddd\n"
51
52 out = text.columnize(items, displaywidth=40, spread=True)
53 assert out == "aaaaa bbbbb ccccc ddddd\n"
54 out = text.columnize(items, displaywidth=20, spread=True)
55 assert out == "aaaaa ccccc\nbbbbb ddddd\n"
56 out = text.columnize(items, displaywidth=12, spread=True)
57 assert out == "aaaaa ccccc\nbbbbb ddddd\n"
58 out = text.columnize(items, displaywidth=10, spread=True)
59 assert out == "aaaaa\nbbbbb\nccccc\nddddd\n"
60
116
61
117
62 def test_columnize_random():
118 def test_columnize_random():
@@ -66,8 +122,11 b' def test_columnize_random():'
66 displaywidth = random.randint(20,200)
122 displaywidth = random.randint(20,200)
67 rand_len = [random.randint(2,displaywidth) for i in range(nitems)]
123 rand_len = [random.randint(2,displaywidth) for i in range(nitems)]
68 items = ['x'*l for l in rand_len]
124 items = ['x'*l for l in rand_len]
69 out = text.columnize(items, row_first=row_first, displaywidth=displaywidth)
125 with pytest.warns(PendingDeprecationWarning):
70 longer_line = max([len(x) for x in out.split('\n')])
126 out = text.columnize(
127 items, row_first=row_first, displaywidth=displaywidth
128 )
129 longer_line = max([len(x) for x in out.split("\n")])
71 longer_element = max(rand_len)
130 longer_element = max(rand_len)
72 assert longer_line <= displaywidth, (
131 assert longer_line <= displaywidth, (
73 f"Columnize displayed something lager than displaywidth : {longer_line}\n"
132 f"Columnize displayed something lager than displaywidth : {longer_line}\n"
@@ -84,7 +143,8 b' def test_columnize_medium(row_first):'
84 """Test with inputs than shouldn't be wider than 80"""
143 """Test with inputs than shouldn't be wider than 80"""
85 size = 40
144 size = 40
86 items = [l*size for l in 'abc']
145 items = [l*size for l in 'abc']
87 out = text.columnize(items, row_first=row_first, displaywidth=80)
146 with pytest.warns(PendingDeprecationWarning):
147 out = text.columnize(items, row_first=row_first, displaywidth=80)
88 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
148 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
89
149
90
150
@@ -93,7 +153,8 b' def test_columnize_long(row_first):'
93 """Test columnize with inputs longer than the display window"""
153 """Test columnize with inputs longer than the display window"""
94 size = 11
154 size = 11
95 items = [l*size for l in 'abc']
155 items = [l*size for l in 'abc']
96 out = text.columnize(items, row_first=row_first, displaywidth=size - 1)
156 with pytest.warns(PendingDeprecationWarning):
157 out = text.columnize(items, row_first=row_first, displaywidth=size - 1)
97 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
158 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
98
159
99
160
General Comments 0
You need to be logged in to leave comments. Login now