378
379
dir_mode=0777, create_parent_dir=True)
379
380
self.assertTransportMode(t, 'dir777', 0777)
382
def test_put_bytes_unicode(self):
383
# Expect put_bytes to raise AssertionError or UnicodeEncodeError if
384
# given unicode "bytes". UnicodeEncodeError doesn't really make sense
385
# (we don't want to encode unicode here at all, callers should be
386
# strictly passing bytes to put_bytes), but we allow it for backwards
387
# compatibility. At some point we should use a specific exception.
388
t = self.get_transport()
391
unicode_string = u'\u1234'
393
(AssertionError, UnicodeEncodeError),
394
t.put_bytes, 'foo', unicode_string)
396
def test_put_file_unicode(self):
397
# Like put_bytes, except with a StringIO.StringIO of a unicode string.
398
# This situation can happen (and has) if code is careless about the type
399
# of "string" they initialise/write to a StringIO with. We cannot use
400
# cStringIO, because it never returns unicode from read.
401
# Like put_bytes, UnicodeEncodeError isn't quite the right exception to
402
# raise, but we raise it for hysterical raisins.
403
t = self.get_transport()
406
unicode_file = pyStringIO(u'\u1234')
407
self.assertRaises(UnicodeEncodeError, t.put_file, 'foo', unicode_file)
381
409
def test_put_multi(self):
382
410
t = self.get_transport()