示例#1
0
 def test_every_line_longer_than_limit(self):
     # sanity check
     lines = [('line %d' % i) * _MAX_ERROR_LINE_LENGTH for i in range(_MAX_ERROR_LINES+2)]
     result = cut_long_message('\n'.join(lines)).splitlines()
     assert_true(_ERROR_CUT_EXPLN in result)
     assert_equal(result[0], lines[0])
     assert_equal(result[-1], lines[-1])
     assert_true(sum(_count_line_lengths(result)) <= _MAX_ERROR_LINES+1)
示例#2
0
 def test_every_line_longer_than_limit(self):
     # sanity check
     lines = [('line %d' % i) * _MAX_ERROR_LINE_LENGTH for i in range(_MAX_ERROR_LINES+2)]
     result = cut_long_message('\n'.join(lines)).splitlines()
     assert_true(_ERROR_CUT_EXPLN in result)
     assert_equal(result[0], lines[0])
     assert_equal(result[-1], lines[-1])
     assert_true(sum(_count_line_lengths(result)) <= _MAX_ERROR_LINES+1)
示例#3
0
 def test_boundary(self):
     b = _MAX_ERROR_LINE_LENGTH
     lengths = [
         b - 1, b, b + 1, 2 * b - 1, 2 * b, 2 * b + 1, 7 * b - 1, 7 * b,
         7 * b + 1
     ]
     lines = ['e' * length for length in lengths]
     assert_equal(_count_line_lengths(lines), [1, 1, 2, 2, 2, 3, 7, 7, 8])
示例#4
0
 def test_correct_number_of_lines(self):
     assert_equal(sum(_count_line_lengths(self.result)), _MAX_ERROR_LINES+1)
示例#5
0
 def test_boundary(self):
     b = _MAX_ERROR_LINE_LENGTH
     lengths = [b-1, b, b+1, 2*b-1, 2*b, 2*b+1, 7*b-1, 7*b, 7*b+1]
     lines = [ 'e'*length for length in lengths ]
     assert_equal(_count_line_lengths(lines), [1, 1, 2, 2, 2, 3, 7, 7, 8])
示例#6
0
 def test_longer_than_max_lines(self):
     lines = [ '1' * i * (_MAX_ERROR_LINE_LENGTH+3) for i in range(4) ]
     assert_equal(_count_line_lengths(lines), [1,2,3,4])
示例#7
0
 def test_shorter_than_max_lines(self):
     lines = ['', '1', 'foo', 'barz and fooz', '', 'a bit longer line', '',
              'This is a somewhat longer (but not long enough) error message']
     assert_equal(_count_line_lengths(lines), [1] * len(lines))
示例#8
0
 def test_empty_line(self):
     assert_equal(_count_line_lengths(['']), [1])
示例#9
0
 def test_no_lines(self):
     assert_equal(_count_line_lengths([]), [])
示例#10
0
 def _assert_basics(self, result, input=None):
     assert_equal(sum(_count_line_lengths(result)), _MAX_ERROR_LINES+1)
     assert_true(_ERROR_CUT_EXPLN in result)
     if input:
         assert_equal(result[0], input[0])
         assert_equal(result[-1], input[-1])
示例#11
0
 def test_correct_number_of_lines(self):
     assert_equal(sum(_count_line_lengths(self.result)),
                  MAX_ERROR_LINES + 1)
示例#12
0
 def test_longer_than_max_lines(self):
     lines = ['1' * i * (_MAX_ERROR_LINE_LENGTH + 3) for i in range(4)]
     assert_equal(_count_line_lengths(lines), [1, 2, 3, 4])
示例#13
0
 def test_shorter_than_max_lines(self):
     lines = [
         '', '1', 'foo', 'barz and fooz', '', 'a bit longer line', '',
         'This is a somewhat longer (but not long enough) error message'
     ]
     assert_equal(_count_line_lengths(lines), [1] * len(lines))
示例#14
0
 def test_empty_line(self):
     assert_equal(_count_line_lengths(['']), [1])
示例#15
0
 def test_no_lines(self):
     assert_equal(_count_line_lengths([]), [])
示例#16
0
 def _assert_basics(self, result, input=None):
     assert_equal(sum(_count_line_lengths(result)), MAX_ERROR_LINES + 1)
     assert_true(_ERROR_CUT_EXPLN in result)
     if input:
         assert_equal(result[0], input[0])
         assert_equal(result[-1], input[-1])