def test_no_preview_no_match(self): """Test no preview because there is no important lines.""" lines = self._make([ 'a', 'b', 'x', 'x', 'x', 'c', 'd', 'e', 'c', 'd', 'e', 'c', 'd', 'e', 'x', 'x', 'x' ]) self.assertListEqual(show._preview_stacktrace(lines, 11, 5), [])
def test_preview_two_parts(self): """Test preview in 2 parts in the middle.""" stack = self._make([ 'a', 'b', 'z', 'x', 'x', 'x', 't-c', 't-d', 't-e', 'x', 'x', 'x', 'z', 'x', 'x', 'x', 't-c', 'x', 'x', 'x', 'x', 'x', 'z' ]) expected = self._make([ 3, 'x', 'x', 'x', 't-c', 't-d', 't-e', 'x', 'x', 'x', 1, 'x', 'x', 'x', 't-c', 'x', 'x', 'x', 3 ]) result = show._preview_stacktrace(stack, 16, 3) self.assertListEqual(result, expected)
def test_preview_two_parts_hit_limit(self): """Test preview in 2 parts in the middle and hit limit.""" stack = self._make([ 'a', 'b', 'z', 'x', 'x', 'x', 't-c', 't-d', 't-e', 'x', 'x', 'x', 'z', 'x', 'x', 'x', 't-c', 'x', 'x', 'x', 'x', 'x', 'z' ]) expected = self._make([ 3, 'x', 'x', 'x', 't-c', 't-d', 't-e', 'x', 13, ]) result = show._preview_stacktrace(stack, 7, 3) self.assertListEqual(result, expected)
def test_preview_middle_and_end(self): """Test preview in the middle and in the end.""" stack = self._make([ 'a', 'b', 'z', 'x', 'x', 'x', 't-c', 't-d', 't-e', 'x', 'x', 'x', 'z' ]) expected = self._make([ 3, 'x', 'x', 'x', 't-c', 't-d', 't-e', 'x', 'x', 'x', 1, ]) result = show._preview_stacktrace(stack, 10, 3) self.assertListEqual(result, expected)
def test_no_preview_small(self): """Test no preview because the stacktrace is so small.""" lines = self._make( ['a', 'b', 'x', 'x', 'x', 't-c', 't-d', 't-e', 'x', 'x', 'x']) self.assertListEqual(show._preview_stacktrace(lines, 11, 5), [])
def test_empty(self): """Test empty stacktrace.""" self.assertListEqual(show._preview_stacktrace([], 10, 3), [])