Add coverage for --color-test

This commit is contained in:
Anthony Sottile
2019-08-04 13:15:45 -07:00
parent a100b03f94
commit 5d12a08146
2 changed files with 15 additions and 5 deletions

12
babi.py
View File

@@ -50,12 +50,15 @@ def _init_colors(stdscr: '_curses._CursesWindow') -> None:
def _color_test(stdscr: '_curses._CursesWindow') -> None:
maxy, maxx = stdscr.getmaxyx()
if maxy < 16 or maxx < 64:
raise SystemExit('--color-test needs a window of at least 64 x 16')
_write_header(stdscr, '<<color test>>', modified=False)
x = y = 0
maxy, maxx = stdscr.getmaxyx()
if maxy < 19 or maxx < 68:
raise SystemExit('--color-test needs a window of at least 68 x 19')
y = 1
for fg in range(-1, 16):
x = 0
for bg in range(-1, 16):
if bg > fg:
s = f'*{COLORS[bg, fg]:3}'
@@ -64,7 +67,6 @@ def _color_test(stdscr: '_curses._CursesWindow') -> None:
stdscr.addstr(y, x, s, _color(fg, bg))
x += 4
y += 1
x = 0
stdscr.get_wch()

View File

@@ -2,6 +2,7 @@ import contextlib
import shlex
import sys
import pytest
from hecate import Runner
import babi
@@ -28,6 +29,13 @@ def await_text_missing(h, text):
raise AssertionError(f'Timeout while waiting for text {text!r} to appear')
@pytest.mark.parametrize('color', (True, False))
def test_color_test(color):
with run('--color-test', color=color) as h:
h.await_text('* 1* 2')
h.press('C-x')
def test_can_start_without_color():
with run(color=False) as h:
h.press('C-x')