From 139484281f0d9320a19b3be4196729bc15326065 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 23 Oct 2019 10:44:17 +0000 Subject: [PATCH] new test: colortest.py - test terminal output + terminfo parsing --- test/colortest.py | 39 +++++++++++++++++++++++++++++++++++++++ test/test-release.sh | 9 ++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 test/colortest.py diff --git a/test/colortest.py b/test/colortest.py new file mode 100755 index 00000000..4d0fb214 --- /dev/null +++ b/test/colortest.py @@ -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 + +""" +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() diff --git a/test/test-release.sh b/test/test-release.sh index 1084e66d..1fdc6f06 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -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"