tests/test_ansicolor.py
author Radek Brich <radek.brich@devl.cz>
Wed, 09 Jul 2014 17:56:05 +0200
changeset 14 6caad95d4540
permissions -rwxr-xr-x
Add test ansicolor.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
from pycolib.ansicolor import highlight, names
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
import unittest
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
class TestAnsiColor(unittest.TestCase):
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
    def test_colors(self):
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
        for fg in range(0,8):
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
            for bg in range(0,8):
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
                print(
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
                    highlight(1, fg, bg),
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
                    '%10s on %-10s' % (names[fg], names[bg]),
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
                    highlight(0),
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
                    sep='', end=''
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
                )
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
            print()
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
if __name__ == '__main__':
6caad95d4540 Add test ansicolor.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
    unittest.main()