colortest.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2021 The MMGen Project <mmgen@tuta.io>
  5. """
  6. colortest.py: test color handling for the MMGen suite
  7. """
  8. import include.tests_header
  9. from include.common import *
  10. from mmgen.color import *
  11. from mmgen.color import _colors
  12. init_color()
  13. def test_color():
  14. try:
  15. import colorama
  16. start_mscolor()
  17. except:
  18. pass
  19. gmsg("Parsed terminfo 'colors' values:")
  20. for t,c in (('rxvt',8),('xterm',8),('rxvt-unicode',88),('screen-256color',256),('xterm-256color',256)):
  21. ret = get_terminfo_colors(t)
  22. if ret == None:
  23. ymsg('Warning: unable to get info for terminal {!r}'.format(t))
  24. continue
  25. msg('{}: {}'.format(t,ret))
  26. assert c == ret, "'colors' value for terminal {} ({}) does not match expected value of {}".format(t,ret,c)
  27. ret = get_terminfo_colors()
  28. msg('This terminal ({}): {}'.format(os.getenv('TERM'),ret))
  29. gmsg("Terminal display:")
  30. for desc,n in (('auto','auto'),('8-color',8),('256-color',256)):
  31. init_color(num_colors=n)
  32. msg('{:9}: {}'.format(desc,' '.join([globals()[c](c) for c in sorted(_colors)])))
  33. test_color()