def test_error_output(self): '''Test error output from command''' cmd = BuildCommand('/bin/bash -c "echo -n FOOBAR 1>&2"') with cmd: cmd.run() self.assertEqual(cmd.output, "") self.assertEqual(cmd.error, "FOOBAR")
def test_missing_command(self): '''Test missing command''' path = os.path.join('non-existant', str(uuid.uuid4())) self.assertFalse(os.path.exists(path)) cmd = BuildCommand('/non-existant/foobar') with cmd: cmd.run() missing_re = re.compile(r'(?:No such file or directory|not found)') self.assertRegexpMatches(cmd.error, missing_re)
def test_result(self): '''Test result of output using unix true/false commands''' cmd = BuildCommand('true') with cmd: cmd.run() self.assertTrue(cmd.successful()) cmd = BuildCommand('false') with cmd: cmd.run() self.assertTrue(cmd.failed())
def test_output(self): '''Test output command''' cmd = BuildCommand('/bin/bash -c "echo -n FOOBAR"') with cmd: cmd.run() self.assertEqual(cmd.output, "FOOBAR")
def test_input(self): '''Test input to command''' cmd = BuildCommand('/bin/cat') with cmd: cmd.run(cmd_input="FOOBAR") self.assertEqual(cmd.output, "FOOBAR")