コード例 #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)
     ])
コード例 #2
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)
         ]
     )
コード例 #3
0
 def _get_bytes(self):
     try:
         return encode_with(next(self.iterator), self.encoding)
     except StopIteration:
         return b""
コード例 #4
0
 def test_equality_content_does_not_equal_bytes(self):
     assert self.part_1.content != encode_with(self.value_1, 'latin-1')
コード例 #5
0
 def test_equality_content_equals_bytes(self):
     assert self.part_1.content == encode_with(self.value_1, 'utf-8')
コード例 #6
0
 def parts_header_equal(part, sample):
     return part.headers[b'Content-Disposition'] == encode_with(
         'form-data; name="{0}"'.format(sample[0]), 'utf-8'
     )
コード例 #7
0
 def parts_equal(part, sample):
     return part.content == encode_with(sample[1], 'utf-8')
コード例 #8
0
 def test_equality_content_does_not_equal_bytes(self):
     assert self.part_1.content != encode_with(self.value_1, 'latin-1')
コード例 #9
0
 def test_equality_content_equals_bytes(self):
     assert self.part_1.content == encode_with(self.value_1, 'utf-8')
コード例 #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')
コード例 #11
0
 def parts_equal(part, sample):
     return part.content == encode_with(sample[1], 'utf-8')