def test_one_huge_line(self): result = cut_long_message('0123456789' * MAX_ERROR_LINES * _MAX_ERROR_LINE_LENGTH) self._assert_basics(result.splitlines()) assert_true(result.startswith('0123456789')) assert_true(result.endswith('0123456789')) assert_true('...\n' + _ERROR_CUT_EXPLN + '\n...' in result)
def test_long_line_cut_after_cut_message(self): lines = ['line %d' % i for i in range(_MAX_ERROR_LINES)] index = _HALF_ERROR_LINES lines[index] = 'abcdefgh' * _MAX_ERROR_LINE_LENGTH result = cut_long_message('\n'.join(lines)).splitlines() self._assert_basics(result, lines) expected = '...' + lines[index][-_MAX_ERROR_LINE_LENGTH+3:] assert_equal(result[index+1], expected)
def test_long_line_cut_before_cut_message(self): lines = ['line %d' % i for i in range(_MAX_ERROR_LINES)] index = _HALF_ERROR_LINES - 1 lines[index] = 'abcdefgh' * _MAX_ERROR_LINE_LENGTH result = cut_long_message('\n'.join(lines)).splitlines() self._assert_basics(result, lines) expected = lines[index][:_MAX_ERROR_LINE_LENGTH-3] + '...' assert_equal(result[index], expected)
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)
def test_long_line_cut_after_cut_message(self): lines = ['line %d' % i for i in range(MAX_ERROR_LINES)] index = _HALF_ERROR_LINES lines[index] = 'abcdefgh' * _MAX_ERROR_LINE_LENGTH result = cut_long_message('\n'.join(lines)).splitlines() self._assert_basics(result, lines) expected = '...' + lines[index][-_MAX_ERROR_LINE_LENGTH + 3:] assert_equal(result[index + 1], expected)
def test_long_line_cut_before_cut_message(self): lines = ['line %d' % i for i in range(MAX_ERROR_LINES)] index = _HALF_ERROR_LINES - 1 lines[index] = 'abcdefgh' * _MAX_ERROR_LINE_LENGTH result = cut_long_message('\n'.join(lines)).splitlines() self._assert_basics(result, lines) expected = lines[index][:_MAX_ERROR_LINE_LENGTH - 3] + '...' assert_equal(result[index], expected)
def setUp(self): self.lines = ['line %d' % i for i in range(_MAX_ERROR_LINES-1)] self.lines.append('x' * (_MAX_ERROR_LINE_LENGTH+1)) self.result = cut_long_message('\n'.join(self.lines)).splitlines()
def setUp(self): self.lines = ['my error message %d' % i for i in range(_MAX_ERROR_LINES+1)] self.result = cut_long_message('\n'.join(self.lines)).splitlines() self.limit = _HALF_ERROR_LINES
def _assert_no_cutting(self, msg): assert_equal(cut_long_message(msg), msg)
def test_one_huge_line(self): result = cut_long_message('0123456789' * _MAX_ERROR_LINES * _MAX_ERROR_LINE_LENGTH) self._assert_basics(result.splitlines()) assert_true(result.startswith('0123456789')) assert_true(result.endswith('0123456789')) assert_true('...\n'+_ERROR_CUT_EXPLN+'\n...' in result)
def setUp(self): self.lines = ['line %d' % i for i in range(MAX_ERROR_LINES - 1)] self.lines.append('x' * (_MAX_ERROR_LINE_LENGTH + 1)) self.result = cut_long_message('\n'.join(self.lines)).splitlines()
def setUp(self): self.lines = [ 'my error message %d' % i for i in range(MAX_ERROR_LINES + 1) ] self.result = cut_long_message('\n'.join(self.lines)).splitlines() self.limit = _HALF_ERROR_LINES