new test: colortest.py - test terminal output + terminfo parsing

This commit is contained in:
The MMGen Project 2019-10-23 10:44:17 +00:00
commit 139484281f
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 47 additions and 1 deletions

39
test/colortest.py Executable file
View file

@ -0,0 +1,39 @@
#!/usr/bin/env python3
#
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
# Copyright (C)2013-2019 The MMGen Project <mmgen@tuta.io>
"""
colortest.py: test color handling for the MMGen suite
"""
import tests_header
from test.common import *
from mmgen.color import *
from mmgen.color import _colors
init_color()
def test_color():
try:
import colorama
colorama.init(strip=True,convert=True)
except:
pass
gmsg("Parsed terminfo 'colors' values:")
for t,c in (('rxvt',8),('xterm',8),('rxvt-unicode',88),('screen-256color',256),('xterm-256color',256)):
ret = get_terminfo_colors(t)
print('{}: {}'.format(t,ret))
assert c == ret, "'colors' value for terminal {} ({}) does not match expected value of {}".format(t,ret,c)
ret = get_terminfo_colors()
msg('This terminal ({}): {}'.format(os.getenv('TERM'),ret))
gmsg("Terminal display:")
for desc,n in (('auto','auto'),('8-color',8),('256-color',256)):
init_color(num_colors=n)
msg('{:9}: {}'.format(desc,' '.join([globals()[c](c) for c in sorted(_colors)])))
test_color()

View file

@ -22,6 +22,7 @@ export PYTHONPATH=.
test_py='test/test.py -n'
objtest_py='test/objtest.py'
objattrtest_py='test/objattrtest.py'
colortest_py='test/colortest.py'
unit_tests_py='test/unit_tests.py --names --quiet'
tooltest_py='test/tooltest.py'
tooltest2_py='test/tooltest2.py --names'
@ -33,7 +34,7 @@ python='python3'
rounds=100 rounds_min=20 rounds_mid=250 rounds_max=500
monero_addrs='3,99,2,22-24,101-104'
dfl_tests='obj unit hash alts monero eth autosign btc btc_tn btc_rt bch bch_rt ltc ltc_tn ltc_rt tool tool2 gen'
dfl_tests='obj color unit hash alts monero eth autosign btc btc_tn btc_rt bch bch_rt ltc ltc_tn ltc_rt tool tool2 gen'
add_tests='autosign_minimal autosign_live'
PROGNAME=$(basename $0)
@ -60,6 +61,7 @@ do
echo " '-V' Run test/test.py and other commands with '--verbose' switch"
echo " AVAILABLE TESTS:"
echo " obj - data objects"
echo " color - color handling"
echo " unit - unit tests"
echo " hash - internal hash function implementations"
echo " alts - operations for all supported gen-only altcoins"
@ -201,6 +203,11 @@ t_obj="
"
f_obj='Data object test complete'
i_color='Color'
s_color='Running color'
t_color="$colortest_py"
f_color='Color tests complete'
i_unit='Unit'
s_unit='Running unit'
t_unit="$unit_tests_py"