Beispiel #1
0
 def bodypart_bytes_from_headers_and_values(headers, value, encoding):
     return b'\r\n\r\n'.join([
         b'\r\n'.join([
             b': '.join([encode_with(i, encoding) for i in h])
             for h in headers
         ]),
         encode_with(value, encoding)
     ])
 def bodypart_bytes_from_headers_and_values(headers, value, encoding):
     return b'\r\n\r\n'.join(
         [
             b'\r\n'.join(
                 [
                     b': '.join([encode_with(i, encoding) for i in h])
                     for h in headers
                 ]
             ),
             encode_with(value, encoding)
         ]
     )
 def _get_bytes(self):
     try:
         return encode_with(next(self.iterator), self.encoding)
     except StopIteration:
         return b""
 def test_equality_content_does_not_equal_bytes(self):
     assert self.part_1.content != encode_with(self.value_1, 'latin-1')
 def test_equality_content_equals_bytes(self):
     assert self.part_1.content == encode_with(self.value_1, 'utf-8')
 def parts_header_equal(part, sample):
     return part.headers[b'Content-Disposition'] == encode_with(
         'form-data; name="{0}"'.format(sample[0]), 'utf-8'
     )
 def parts_equal(part, sample):
     return part.content == encode_with(sample[1], 'utf-8')
Beispiel #8
0
 def test_equality_content_does_not_equal_bytes(self):
     assert self.part_1.content != encode_with(self.value_1, 'latin-1')
Beispiel #9
0
 def test_equality_content_equals_bytes(self):
     assert self.part_1.content == encode_with(self.value_1, 'utf-8')
Beispiel #10
0
 def parts_header_equal(part, sample):
     return part.headers[b'Content-Disposition'] == encode_with(
         'form-data; name="{0}"'.format(sample[0]), 'utf-8')
Beispiel #11
0
 def parts_equal(part, sample):
     return part.content == encode_with(sample[1], 'utf-8')