Пример #1
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_lenghts(lines), [1, 1, 2, 2, 2, 3, 7, 7, 8])
Пример #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_lenghts(result)) <= _MAX_ERROR_LINES+1)
Пример #3
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_lenghts(result)) <= _MAX_ERROR_LINES + 1)
Пример #4
0
 def test_correct_number_of_lines(self):
     assert_equal(sum(_count_line_lenghts(self.result)),
                  _MAX_ERROR_LINES + 1)
Пример #5
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_lenghts(lines), [1, 2, 3, 4])
Пример #6
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_lenghts(lines), [1] * len(lines))
Пример #7
0
 def test_empty_line(self):
     assert_equal(_count_line_lenghts(['']), [1])
Пример #8
0
 def test_no_lines(self):
     assert_equal(_count_line_lenghts([]), [])
Пример #9
0
 def _assert_basics(self, result, input=None):
     assert_equal(sum(_count_line_lenghts(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])
Пример #10
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_lenghts(lines), [1, 1, 2, 2, 2, 3, 7, 7, 8])
Пример #11
0
 def test_correct_number_of_lines(self):
     assert_equal(sum(_count_line_lenghts(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_lenghts(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_lenghts(lines), [1] * len(lines))
Пример #14
0
 def test_empty_line(self):
     assert_equal(_count_line_lenghts(['']), [1])
Пример #15
0
 def test_no_lines(self):
     assert_equal(_count_line_lenghts([]), [])
Пример #16
0
 def _assert_basics(self, result, input=None):
     assert_equal(sum(_count_line_lenghts(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])