Ejemplo n.º 1
0
 def setUp(self):
     self.header_1 = (TestBodyPart.u('Snowman'), TestBodyPart.u('☃'))
     self.value_1 = TestBodyPart.u('©')
     self.part_1 = BodyPart(
         TestBodyPart.bodypart_bytes_from_headers_and_values(
             (self.header_1, ), self.value_1, 'utf-8'), 'utf-8')
     self.part_2 = BodyPart(
         TestBodyPart.bodypart_bytes_from_headers_and_values([],
                                                             self.value_1,
                                                             'utf-16'),
         'utf-16')
Ejemplo n.º 2
0
 def test_equality_content_should_be_equal(self):
     part_3 = BodyPart(
         TestBodyPart.bodypart_bytes_from_headers_and_values([],
                                                             self.value_1,
                                                             'utf-8'),
         'utf-8')
     assert self.part_1.content == part_3.content
Ejemplo n.º 3
0
 def test_no_crlf_crlf_in_content(self):
     content = b'no CRLF CRLF here!\r\n'
     with pytest.raises(ImproperBodyPartContentException):
         BodyPart(content, 'utf-8')
Ejemplo n.º 4
0
 def test_no_headers(self):
     sample_1 = b'\r\n\r\nNo headers\r\nTwo lines'
     part_3 = BodyPart(sample_1, 'utf-8')
     assert len(part_3.headers) == 0
     assert part_3.content == b'No headers\r\nTwo lines'