示例#1
0
def test_output_disabled():
    log = ansi_print.AnsiLogger('test')
    with FakeOutput() as output:
        log('Hello')
        log.output_disabled = True
        log('World')
    assert output == [('[test] Hello\n', ())]
示例#2
0
def test_unknown_method_names():
    log = ansi_print.AnsiLogger('test')
    with FakeOutput() as output:
        log.foo('Hello')
        log.foo('World')
        log.BAR('!')
    assert output == [('[test:foo] Hello\n', ()), ('[test:foo] World\n', ()),
                      ('[test:BAR] !\n', ())]
示例#3
0
def test_no_tty():
    log = ansi_print.AnsiLogger('test')
    with FakeOutput(tty=False) as output:
        log.dot()
        log.dot()
        log.WARNING('oops')
        log.WARNING('maybe?')
        log.dot()
    assert len(output) == 2
    assert output[0] == ('[test:WARNING] oops\n', ())
    assert output[1] == ('[test:WARNING] maybe?\n', ())
示例#4
0
def test_dot_mixing_with_regular_lines():
    log = ansi_print.AnsiLogger('test')
    with FakeOutput() as output:
        log.dot()
        log.dot()
        log.WARNING('oops')
        log.WARNING('maybe?')
        log.dot()
    assert len(output) == 5
    assert len(output[0][0]) == 1  # single character
    assert len(output[1][0]) == 1  # single character
    assert output[2] == ('\n[test:WARNING] oops\n', (31, ))
    assert output[3] == ('[test:WARNING] maybe?\n', (31, ))
    assert len(output[4][0]) == 1  # single character
示例#5
0
def test_dot_1():
    log = ansi_print.AnsiLogger('test')
    with FakeOutput() as output:
        log.dot()
    assert len(output) == 1
    assert len(output[0][0]) == 1  # single character
示例#6
0
def test_not_a_tty():
    log = ansi_print.AnsiLogger('test')
    with FakeOutput(tty=False) as output:
        log.bold('Hello')
    assert output == [('[test] Hello\n', ())]
示例#7
0
def test_bold():
    log = ansi_print.AnsiLogger('test')
    with FakeOutput() as output:
        log.bold('Hello')
    assert output == [('[test] Hello\n', (1, ))]
示例#8
0
def test_simple():
    log = ansi_print.AnsiLogger('test')
    with FakeOutput() as output:
        log('Hello')
    assert output == [('[test] Hello\n', ())]