def test_with_bytes_output_types(self):
        # accepts unicode
        def f(data, expected):
            with self.withBytesOutput() as (out, err):
                for d in data:
                    out.write(d)
            self.assertEqual(out.getvalue(), expected)

        f(['あいうえお'], 'あいうえお'.encode('utf-8'))
        f([b'\xff', 'あいうえお'], b'\xff' + 'あいうえお'.encode('utf-8'))

        # accepts only string-like types
        self.assertRaises(TypeError, f, [[]])
        self.assertRaises(TypeError, f, [{'a': 20}])
        self.assertRaises(TypeError, f, [1.23])