Пример #1
0
def test_log_execute_output(capfd):
    op = Operation([u'echo', u'hello world'])
    logs = []

    def log(msg, **kwargs):
        logs.append(msg)

    op.execute(log)
    assert logs == [u'echo hello world', u'hello world']
    assert capfd.readouterr() == (u'hello world\r\n', '')
Пример #2
0
def test_shell_operation(capfd):
    # must be able to read env. variables
    test = os.environ['PYTEST_CURRENT_TEST']
    op = Operation('echo $PYTEST_CURRENT_TEST', shell=True)
    logs = []

    def log(msg, **kwargs):
        logs.append(msg)

    op.execute(log)
    assert logs == [u'echo $PYTEST_CURRENT_TEST', test]
    assert capfd.readouterr() == (u'%s\r\n' % test, '')
Пример #3
0
 def test_from_list_of_str(self):
     op = Operation(['ls', '-l'])
     self.assertEqual(op.command, ['ls', '-l'])
Пример #4
0
 def test_from_list_of_unicode(self):
     op = Operation([u'ls', u'-l'])
     self.assertEqual(op.command, ['ls', '-l'])
Пример #5
0
 def test_from_single_str(self):
     op = Operation('ls -l')
     self.assertEqual(op.command, ['ls', '-l'])
Пример #6
0
def test_from_single_unicode():
    op = Operation(u'ls -l')
    assert op.command == ['ls', '-l']
Пример #7
0
def test_from_list_of_str():
    op = Operation(['ls', '-l'])
    assert op.command == ['ls', '-l']
Пример #8
0
def test_from_list_of_unicode():
    op = Operation([u'ls', u'-l'])
    assert op.command == ['ls', '-l']
Пример #9
0
def test_from_single_str():
    op = Operation('ls -l')
    assert op.command == ['ls', '-l']