MCPcopy Create free account
hub / github.com/ipython/ipython / test_columnize_random

Function test_columnize_random

IPython/utils/tests/test_text.py:62–78  ·  view source on GitHub ↗

Test with random input to hopefully catch edge case

()

Source from the content-addressed store, hash-verified

60
61
62def test_columnize_random():
63 """Test with random input to hopefully catch edge case """
64 for row_first in [True, False]:
65 for nitems in [random.randint(2,70) for i in range(2,20)]:
66 displaywidth = random.randint(20,200)
67 rand_len = [random.randint(2,displaywidth) for i in range(nitems)]
68 items = ['x'*l for l in rand_len]
69 out = text.columnize(items, row_first=row_first, displaywidth=displaywidth)
70 longer_line = max([len(x) for x in out.split('\n')])
71 longer_element = max(rand_len)
72 if longer_line > displaywidth:
73 print("Columnize displayed something lager than displaywidth : %s " % longer_line)
74 print("longer element : %s " % longer_element)
75 print("displaywidth : %s " % displaywidth)
76 print("number of element : %s " % nitems)
77 print("size of each element :\n %s" % rand_len)
78 assert False, "row_first={0}".format(row_first)
79
80def test_columnize_medium():
81 """Test with inputs than shouldn't be wider than 80"""

Callers

nothing calls this directly

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected