def __init__(self, size, iterator, md5, encoding="utf-8"): #: The expected size of the upload self.size = int(size) self.md5 = md5 if self.size < 0: raise ValueError( "The size of the upload must be a positive integer") #: Attribute that requests will check to determine the length of the #: body. See bug #80 for more details self.len = self.size #: The iterator used to generate the upload data self.iterator = iterator #: Encoding the iterator is using self.encoding = encoding # The buffer we use to provide the correct number of bytes requested # during a read self._buffer = CustomBytesIO()
def test_accepts_encoded_strings_with_unicode(self): """Accepts a string with encoded unicode characters.""" s = b'this is a unicode string: \xc3\xa9 \xc3\xa1 \xc7\xab \xc3\xb3' self.instance = CustomBytesIO(s) assert self.instance.read() == s
def setUp(self): self.instance = CustomBytesIO()