def test_add(self):
     result = r('echo 2; false', mode=Collect) + r('echo 3; true', mode=Collect)
     self.assertEqual('2\n3\n', result.stdout())
     self.assertTrue(result)
     result = r('echo 2; true', mode=Collect) + r('echo 3; false', mode=Collect)
     self.assertEqual('2\n3\n', result.stdout())
     self.assertFalse(result)
 def test_multiple_lines(self):
     self.assertEqual('2\n3\n', r('echo 2; echo 3', mode=Collect).stdout())
     self.assertRaises(RuntimeError, lambda: r('echo 2; echo 3', mode=Collect).stdout(single_line=True))
     self.assertEqual(['2', '3'], r('echo 2; echo 3', mode=Collect).stdout(as_lines=True))
     self.assertRaises(RuntimeError, lambda: r('echo 2; echo 3', mode=Collect).stdout(as_lines=True, single_line=True))
     self.assertRaises(RuntimeError, lambda: r('echo 2; echo 3', mode=Collect).stdout(as_lines=True, raw=True))
     self.assertRaises(RuntimeError, lambda: r('echo 2; echo 3', mode=Collect).stdout(single_line=True, raw=True))
     self.assertRaises(RuntimeError, lambda: r('echo 2; echo 3', mode=Collect).stdout(as_lines=True, single_line=True, raw=True))
 def test_return_value(self):
     self.assertEqual("", repr(r('true')))
 def test_exit_code(self):
     self.assertEqual(True, bool(r('true')))
     self.assertEqual(False, bool(r('false')))
 def test_raw_output(self):
     self.assertEqual(["2\n", "3\n"], r('echo 2; echo 3', mode=Collect).stdout(raw=True))
     self.assertEqual([b"2\n", b"3\n"], r('echo 2; echo 3', mode=Collect, raw_bytes=True).stdout(raw=True))
     self.assertEqual("2\n3\n", r('echo 2; echo 3', mode=Collect, raw_bytes=True).stdout())
 def test_invalid_args(self):
     self.assertRaises(RuntimeError, lambda: r(None))
     self.assertRaises(RuntimeError, lambda: re(['a']))