Skip to content

Commit 313189c

Browse files
tests for clearing, fix issue #343
1 parent 9d48733 commit 313189c

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,9 +1006,11 @@ def paint(self, about_to_exit=False, user_quit=False):
10061006
width, min_height = self.width, self.height
10071007
show_status_bar = bool(self.status_bar.should_show_message) or self.status_bar.has_focus
10081008
if show_status_bar:
1009-
min_height -= 1
1009+
min_height -= 1 # because we're going to tack the status bar on at the end,
1010+
# shoot for an array one less than the height of the screen
10101011

10111012
current_line_start_row = len(self.lines_for_display) - max(0, self.scroll_offset)
1013+
#TODO how is the situation of self.scroll_offset < 0 possible?
10121014
#current_line_start_row = len(self.lines_for_display) - self.scroll_offset
10131015
if self.request_paint_to_clear_screen: # or show_status_bar and about_to_exit ?
10141016
self.request_paint_to_clear_screen = False
@@ -1098,7 +1100,7 @@ def paint(self, about_to_exit=False, user_quit=False):
10981100

10991101
logger.debug('about to exit: %r', about_to_exit)
11001102
if show_status_bar:
1101-
statusbar_row = min_height + 1 if arr.height == min_height else arr.height
1103+
statusbar_row = min_height if arr.height == min_height else arr.height
11021104
if about_to_exit:
11031105
arr[statusbar_row, :] = FSArray(1, width)
11041106
else:

bpython/test/test_curtsies_painting.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def test_completion(self):
7171
u'┌───────────────────────┐',
7272
u'│ set( setattr( │',
7373
u'└───────────────────────┘',
74-
u'',
7574
u'Welcome to bpython! Press <F1> f']
7675
self.assert_paint_ignoring_formatting(screen, (0, 4))
7776

@@ -126,7 +125,6 @@ def test_rewind(self):
126125
screen = [u'>>> ']
127126
self.assert_paint_ignoring_formatting(screen, (0, 4))
128127

129-
@skip('wrong message')
130128
def test_rewind_contiguity_loss(self):
131129
self.enter('1 + 1')
132130
self.enter('2 + 2')
@@ -182,7 +180,7 @@ def test_inconsistent_history_doesnt_happen_if_onscreen(self):
182180
u'>>> ']
183181
self.assert_paint_ignoring_formatting(screen, (2, 4))
184182

185-
@skip('why is everything moved up?')
183+
@skip('for inconsistent history check')
186184
def test_rewind_inconsistent_history(self):
187185
self.enter("1 + 1")
188186
self.enter("2 + 2")
@@ -224,8 +222,7 @@ def test_clear_screen(self):
224222
u'>>> ', u'', u'', u'', u'']
225223
self.assert_paint_ignoring_formatting(screen, (4, 4))
226224

227-
@skip('the screen moved up again!')
228-
def test_clear_screen_while_banner_visible(self):
225+
def test_scroll_down_while_banner_visible(self):
229226
self.repl.status_bar.message('STATUS_BAR')
230227
self.enter("1 + 1")
231228
self.enter("2 + 2")
@@ -239,12 +236,25 @@ def test_clear_screen_while_banner_visible(self):
239236
self.repl.scroll_offset += len(screen) - self.repl.height
240237
self.assert_paint_ignoring_formatting(screen[1:], (3, 4))
241238

242-
self.repl.request_paint_to_clear_screen = True
239+
def test_clear_screen_while_banner_visible(self):
240+
self.repl.status_bar.message('STATUS_BAR')
241+
self.enter("1 + 1")
242+
self.enter("2 + 2")
243243
screen = [u">>> 1 + 1",
244244
u'2',
245+
u'>>> 2 + 2',
246+
u'4',
247+
u'>>> ',
248+
u'STATUS_BAR ']
249+
self.assert_paint_ignoring_formatting(screen, (4, 4))
250+
self.repl.scroll_offset += len(screen) - self.repl.height
251+
self.assert_paint_ignoring_formatting(screen[1:], (3, 4))
252+
253+
self.repl.request_paint_to_clear_screen = True
254+
screen = [u'2',
245255
u'>>> 2 + 2',
246256
u'4',
247257
u'>>> ',
248258
u'', u'', u'',
249259
u'STATUS_BAR ']
250-
self.assert_paint_ignoring_formatting(screen, (0, 4))
260+
self.assert_paint_ignoring_formatting(screen, (3, 4))

0 commit comments

Comments
 (0)