예제 #1
0
    def test_labeled_out(self):
        with FakeEcho.simple('testing') as fe:
            labeled_out('testing')
        assert fe.was_called()

        with FakeEcho.simple('ERROR: testing') as fe:
            labeled_out('testing', label='ERROR')
        assert fe.was_called()
예제 #2
0
    def test_out_ignore_quiet(self):
        with Options(quiet=True):
            with FakeEcho.simple('test') as fe:
                out('test', respect_quiet=False)
        assert fe.was_called()

        with FakeEcho.simple('test') as fe:
            out('test', respect_quiet=False)
        assert fe.was_called()
예제 #3
0
    def test_verbose_out_verbose(self):
        with Options(verbose=1):
            with FakeEcho.simple('test', fg='white') as fe:
                verbose_out('test', fg='white')
            assert fe.was_called()

            with FakeEcho.simple('test', fg='green') as fe:
                verbose_out('test')
            assert fe.was_called()
예제 #4
0
    def test_warn_out(self):
        with FakeEcho.simple('Warning: testing', fg='yellow') as fe:
            warn('testing')
        assert fe.was_called()

        with FakeEcho.simple('ERROR: testing', fg='yellow') as fe:
            warn('testing', label='ERROR')
        assert fe.was_called()

        with Options(quiet=True):
            with FakeEcho.simple('Warning: testing', fg='yellow') as fe:
                warn('testing')
            assert fe.was_called()
예제 #5
0
    def test_allowed_rc(self):
        cmd_line = ['ls', '-l']

        with FakeEcho(None) as fe:
            with FakeProcessContext(FakeProcess(cmd_line, rc=2)):
                checked_run(cmd_line, 'Testing', allowed_rcs=[2])
        assert not fe.was_called()
예제 #6
0
    def test_verbose_output(self):
        cmd_line = ['ls', '-l']

        with Options(verbose=1):
            with FakeEcho.simple('Running: ls -l', fg='green') as fe:
                with FakeProcessContext(FakeProcess(cmd_line)):
                    checked_run(cmd_line, 'Testing')
            assert fe.was_called()
예제 #7
0
    def test_failure_output(self):
        cmd_line = ['ls', '-l']
        expected = [
            ExpectedEcho(r'ERROR: Testing failed with return code 2\.', fg='bright_red'),
            ExpectedEcho(r'ERROR: Command line: ls -l', fg='bright_red')
        ]

        with FakeEcho(expected) as fe:
            with FakeProcessContext(FakeProcess(cmd_line, rc=2)):
                with pytest.raises(SystemExit):
                    checked_run(cmd_line, 'Testing')
        assert fe.was_called()
예제 #8
0
    def test_print_available_tasks(self):
        module_set = ModuleSet(_unambiguous())
        expected = [
            ExpectedEcho(r'    m1', fg="white"),
            ExpectedEcho(r'        %s -- %s' % (_encode(
                't1', fg='bright_green'), _encode('None', fg='green'))),
            ExpectedEcho(r'        %s -- %s' % (_encode(
                't2', fg='bright_green'), _encode('None', fg='green'))),
            ExpectedEcho(r''),
            ExpectedEcho(r'    m2', fg="white"),
            ExpectedEcho(r'        %s -- %s' % (_encode(
                't3', fg='bright_green'), _encode('None', fg='green'))),
            ExpectedEcho(r'        %s -- %s' % (_encode(
                't4', fg='bright_green'), _encode('None', fg='green'))),
            ExpectedEcho(r'')
        ]

        with FakeEcho(expected):
            module_set.print_available_tasks()
예제 #9
0
 def test_end(self):
     with FakeEcho.simple('ERROR: boom!', fg='bright_red') as fe:
         with pytest.raises(SystemExit):
             end('boom!')
     assert fe.was_called()
예제 #10
0
 def test_simple_verbose_out(self):
     with FakeEcho.simple('test') as fe:
         verbose_out('test')
     assert not fe.was_called()
예제 #11
0
 def test_out_quiet(self):
     with Options(quiet=True):
         with FakeEcho.simple('test') as fe:
             out('test')
     assert not fe.was_called()
예제 #12
0
 def test_out_with_kwargs(self):
     with FakeEcho.simple('test', fg='white') as fe:
         out('test', fg='white')
     assert fe.was_called()
예제 #13
0
 def test_bad_module_import(self):
     with FakeImporter(fail=True):
         with FakeEcho.simple(
                 'Warning: Exception loading module for test: boom!',
                 fg='yellow'):
             assert get_language_module('test') is None