def test_should_return_the_generator_for_a_generator_output(self):
        mock = _mock_dir_entry_generator()

        prev_input, tup = _process_output(mock, 'test')

        self.assertIsInstance(prev_input, GeneratorType)
        self.assertIsNone(tup)
    def test_should_return_stdout_for_a_process_output(self):
        mock = _mock_process()

        prev_input, (output, action_key) = _process_output(mock, 'test')

        self.assertEqual('process:stdout', prev_input)
        self.assertIsInstance(output, Popen)
        self.assertEqual(mock, output)
        self.assertEqual('test', action_key)
    def test_should_return_raw_stream_for_a_buffered_raw_stream_output(self):
        mock = _mock_buffered_io_stream()

        prev_input, (output, action_key) = _process_output(mock, 'test')

        self.assertIsInstance(prev_input, FileIO)
        self.assertIsInstance(output, BufferedIOBase)
        self.assertEqual(mock, output)
        self.assertEqual('test', action_key)
    def test_should_raise_if_buffered_raw_stream_does_not_point_to_a_file_io(self):
        mock = _mock_buffered_io_stream(bad=True)

        with self.assertRaisesRegex(IOError, r'.+must contain a io.FileIO.+'):
            _process_output(mock, 'test')
 def test_should_fail_with_unsupported_output(self):
     with self.assertRaisesRegex(Exception, r'Unsupported output type <.*?> for \w+'):
         _process_output(None, 'test')