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', '')
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, '')
def test_from_list_of_str(self): op = Operation(['ls', '-l']) self.assertEqual(op.command, ['ls', '-l'])
def test_from_list_of_unicode(self): op = Operation([u'ls', u'-l']) self.assertEqual(op.command, ['ls', '-l'])
def test_from_single_str(self): op = Operation('ls -l') self.assertEqual(op.command, ['ls', '-l'])
def test_from_single_unicode(): op = Operation(u'ls -l') assert op.command == ['ls', '-l']
def test_from_list_of_str(): op = Operation(['ls', '-l']) assert op.command == ['ls', '-l']
def test_from_list_of_unicode(): op = Operation([u'ls', u'-l']) assert op.command == ['ls', '-l']
def test_from_single_str(): op = Operation('ls -l') assert op.command == ['ls', '-l']