def test_truncates_at_1_line_when_first_line_is_GT_max_chars(self): expl = ["a" * 250 for x in range(1000)] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=100) assert result != expl assert len(result) == 1 + self.LINES_IN_TRUNCATION_MSG assert "Full output truncated" in result[-1] assert "1000 lines hidden" in result[-1] last_line_before_trunc_msg = result[-self.LINES_IN_TRUNCATION_MSG - 1] assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_8_lines_when_first_8_lines_are_EQ_max_chars(self): expl = ['a' * 80 for x in range(16)] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=8 * 80) assert result != expl assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG assert "Full output truncated" in result[-1] assert "9 lines hidden" in result[-1] last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG - 1] assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_8_lines_when_given_list_of_empty_strings(self): expl = ["" for x in range(50)] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=100) assert result != expl assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG assert "Full output truncated" in result[-1] assert "43 lines hidden" in result[-1] last_line_before_trunc_msg = result[-self.LINES_IN_TRUNCATION_MSG - 1] assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_1_line_when_first_line_is_GT_max_chars(self): expl = ['a' * 250 for x in range(1000)] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=100) assert result != expl assert len(result) == 1 + self.LINES_IN_TRUNCATION_MSG assert "Full output truncated" in result[-1] assert "1000 lines hidden" in result[-1] last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG - 1] assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_8_lines_when_given_list_of_empty_strings(self): expl = ['' for x in range(50)] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=100) assert result != expl assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG assert "Full output truncated" in result[-1] assert "43 lines hidden" in result[-1] last_line_before_trunc_msg = result[- self.LINES_IN_TRUNCATION_MSG - 1] assert last_line_before_trunc_msg.endswith("...")
def test_truncates_at_8_lines_when_first_8_lines_are_EQ_max_chars(self): expl = ["a" * 80 for x in range(16)] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=8 * 80) assert result != expl assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG assert "Full output truncated" in result[-1] assert "9 lines hidden" in result[-1] last_line_before_trunc_msg = result[-self.LINES_IN_TRUNCATION_MSG - 1] assert last_line_before_trunc_msg.endswith("...")
def test_doesnt_truncate_at_when_input_is_5_lines_and_LT_max_chars(self): expl = ['a' * 100 for x in range(5)] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=8 * 80) assert result == expl
def test_doesnt_truncate_when_input_is_empty_list(self): expl = [] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=100) assert result == expl
def test_doesnt_truncate_at_when_input_is_5_lines_and_LT_max_chars(self): expl = ['a' * 100 for x in range(5)] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=8 * 80) assert result == expl
def test_doesnt_truncate_when_input_is_empty_list(self): expl = [] result = truncate._truncate_explanation(expl, max_lines=8, max_chars=100) assert result == expl