1
- import os
1
+ import os , sys
2
2
3
3
import pyte
4
4
from pyte import control as ctrl , modes as mo
5
5
6
+ sys .path .append (os .path .join (os .path .dirname (__file__ ), "helpers" ))
7
+ from asserts import consistency_asserts
6
8
7
9
def chars (history_lines , columns ):
8
10
return ["" .join (history_lines [y ][x ].data for x in range (columns ))
@@ -96,6 +98,7 @@ def test_prev_page():
96
98
"39 " ,
97
99
" "
98
100
]
101
+ consistency_asserts (screen )
99
102
100
103
assert chars (screen .history .top , screen .columns )[- 4 :] == [
101
104
"33 " ,
@@ -114,6 +117,7 @@ def test_prev_page():
114
117
"37 " ,
115
118
"38 "
116
119
]
120
+ consistency_asserts (screen )
117
121
118
122
assert chars (screen .history .top , screen .columns )[- 4 :] == [
119
123
"31 " ,
@@ -138,6 +142,7 @@ def test_prev_page():
138
142
"35 " ,
139
143
"36 " ,
140
144
]
145
+ consistency_asserts (screen )
141
146
142
147
assert len (screen .history .bottom ) == 4
143
148
assert chars (screen .history .bottom , screen .columns ) == [
@@ -165,6 +170,7 @@ def test_prev_page():
165
170
"49 " ,
166
171
" "
167
172
]
173
+ consistency_asserts (screen )
168
174
169
175
screen .prev_page ()
170
176
assert screen .history .position == 47
@@ -175,6 +181,7 @@ def test_prev_page():
175
181
"46 " ,
176
182
"47 "
177
183
]
184
+ consistency_asserts (screen )
178
185
179
186
assert len (screen .history .bottom ) == 3
180
187
assert chars (screen .history .bottom , screen .columns ) == [
@@ -200,6 +207,7 @@ def test_prev_page():
200
207
"39 " ,
201
208
" "
202
209
]
210
+ consistency_asserts (screen )
203
211
204
212
screen .prev_page ()
205
213
assert screen .history .position == 37
@@ -209,6 +217,7 @@ def test_prev_page():
209
217
"36 " ,
210
218
"37 "
211
219
]
220
+ consistency_asserts (screen )
212
221
213
222
assert len (screen .history .bottom ) == 3
214
223
assert chars (screen .history .bottom , screen .columns ) == [
@@ -235,6 +244,7 @@ def test_prev_page():
235
244
"49 " ,
236
245
" "
237
246
]
247
+ consistency_asserts (screen )
238
248
239
249
screen .cursor_to_line (screen .lines // 2 )
240
250
@@ -250,6 +260,7 @@ def test_prev_page():
250
260
"4 " ,
251
261
"5 "
252
262
]
263
+ consistency_asserts (screen )
253
264
254
265
while screen .history .position < screen .history .size :
255
266
screen .next_page ()
@@ -262,6 +273,7 @@ def test_prev_page():
262
273
"49 " ,
263
274
" "
264
275
]
276
+ consistency_asserts (screen )
265
277
266
278
# e) same with cursor near the middle of the screen.
267
279
screen = pyte .HistoryScreen (5 , 5 , history = 50 )
@@ -282,6 +294,7 @@ def test_prev_page():
282
294
"49 " ,
283
295
" "
284
296
]
297
+ consistency_asserts (screen )
285
298
286
299
screen .cursor_to_line (screen .lines // 2 - 2 )
287
300
@@ -297,6 +310,7 @@ def test_prev_page():
297
310
"4 " ,
298
311
"5 "
299
312
]
313
+ consistency_asserts (screen )
300
314
301
315
while screen .history .position < screen .history .size :
302
316
screen .next_page ()
@@ -310,6 +324,7 @@ def test_prev_page():
310
324
"49 " ,
311
325
" "
312
326
]
327
+ consistency_asserts (screen )
313
328
314
329
315
330
def test_next_page ():
@@ -332,6 +347,7 @@ def test_next_page():
332
347
"24 " ,
333
348
" "
334
349
]
350
+ consistency_asserts (screen )
335
351
336
352
# a) page up -- page down.
337
353
screen .prev_page ()
@@ -346,6 +362,7 @@ def test_next_page():
346
362
"24 " ,
347
363
" "
348
364
]
365
+ consistency_asserts (screen )
349
366
350
367
# b) double page up -- page down.
351
368
screen .prev_page ()
@@ -366,6 +383,7 @@ def test_next_page():
366
383
"21 " ,
367
384
"22 "
368
385
]
386
+ consistency_asserts (screen )
369
387
370
388
# c) double page up -- double page down
371
389
screen .prev_page ()
@@ -381,6 +399,7 @@ def test_next_page():
381
399
"21 " ,
382
400
"22 "
383
401
]
402
+ consistency_asserts (screen )
384
403
385
404
386
405
def test_ensure_width (monkeypatch ):
@@ -402,6 +421,7 @@ def test_ensure_width(monkeypatch):
402
421
"0024 " ,
403
422
" "
404
423
]
424
+ consistency_asserts (screen )
405
425
406
426
# Shrinking the screen should truncate the displayed lines following lines.
407
427
screen .resize (5 , 3 )
@@ -416,6 +436,7 @@ def test_ensure_width(monkeypatch):
416
436
"002" , # 21
417
437
"002" # 22
418
438
]
439
+ consistency_asserts (screen )
419
440
420
441
421
442
def test_not_enough_lines ():
@@ -436,6 +457,7 @@ def test_not_enough_lines():
436
457
"4 " ,
437
458
" "
438
459
]
460
+ consistency_asserts (screen )
439
461
440
462
screen .prev_page ()
441
463
assert not screen .history .top
@@ -448,6 +470,7 @@ def test_not_enough_lines():
448
470
"3 " ,
449
471
"4 " ,
450
472
]
473
+ consistency_asserts (screen )
451
474
452
475
screen .next_page ()
453
476
assert screen .history .top
@@ -459,6 +482,7 @@ def test_not_enough_lines():
459
482
"4 " ,
460
483
" "
461
484
]
485
+ consistency_asserts (screen )
462
486
463
487
464
488
def test_draw (monkeypatch ):
@@ -479,6 +503,7 @@ def test_draw(monkeypatch):
479
503
"24 " ,
480
504
" "
481
505
]
506
+ consistency_asserts (screen )
482
507
483
508
# a) doing a pageup and then a draw -- expecting the screen
484
509
# to scroll to the bottom before drawing anything.
@@ -494,6 +519,7 @@ def test_draw(monkeypatch):
494
519
"24 " ,
495
520
"x "
496
521
]
522
+ consistency_asserts (screen )
497
523
498
524
499
525
def test_cursor_is_hidden (monkeypatch ):
0 commit comments