~terceiro/lava-dispatcher/filter-ansi-color-codes-mwhudson-state-machine

« back to all changes in this revision

Viewing changes to lava_dispatcher/tests/test_utils.py

  • Committer: Antonio Terceiro
  • Date: 2013-08-02 16:58:43 UTC
  • Revision ID: antonio.terceiro@linaro.org-20130802165843-1l66e1vii35pef70
Need to filter out non-color codes as well, such as cursor positioning, screen
clearing etc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from unittest import TestCase
21
21
import pexpect
22
22
 
 
23
import os
 
24
 
23
25
from lava_dispatcher.utils import logging_spawn
24
26
 
25
27
class TestLoggingSpawn(TestCase):
27
29
    def test_filter_out_ansi_color_codes(self):
28
30
        proc = logging_spawn('printf "I AM \033[1mOK\033[m\n"')  # OK in bold
29
31
        proc.expect(["I AM OK", pexpect.EOF])
30
 
        assert(proc.match != pexpect.EOF)
 
32
        self.assertIsNot(proc.match, pexpect.EOF)
31
33
 
32
34
    def test_filter_out_multiple_ansi_color_escape_sequences(self):
33
35
        # "I AM" in bold light green, "OK" in bold
34
36
        proc = logging_spawn('printf "\033[1;32;40mI AM\033[m \033[1mOK\033[m\n"')
35
37
        proc.expect(["I AM OK", pexpect.EOF])
36
 
        assert(proc.match != pexpect.EOF)
 
38
        self.assertIsNot(proc.match, pexpect.EOF)
 
39
 
 
40
    def test_filter_out_cursor_positioning_codes(self):
 
41
        proc = logging_spawn('printf "I AM \033[23;01H\033[1mOK\033[m\n"')
 
42
        proc.expect(["I AM OK", pexpect.EOF])
 
43
        self.assertIsNot(proc.match, pexpect.EOF)