test_vt100_output.py 693 B

1234567891011121314151617181920
  1. from __future__ import annotations
  2. from prompt_toolkit.output.vt100 import _get_closest_ansi_color
  3. def test_get_closest_ansi_color():
  4. # White
  5. assert _get_closest_ansi_color(255, 255, 255) == "ansiwhite"
  6. assert _get_closest_ansi_color(250, 250, 250) == "ansiwhite"
  7. # Black
  8. assert _get_closest_ansi_color(0, 0, 0) == "ansiblack"
  9. assert _get_closest_ansi_color(5, 5, 5) == "ansiblack"
  10. # Green
  11. assert _get_closest_ansi_color(0, 255, 0) == "ansibrightgreen"
  12. assert _get_closest_ansi_color(10, 255, 0) == "ansibrightgreen"
  13. assert _get_closest_ansi_color(0, 255, 10) == "ansibrightgreen"
  14. assert _get_closest_ansi_color(220, 220, 100) == "ansiyellow"