我们从Python开源项目中,提取了以下19个代码示例,用于说明如何使用email.generator.DecodedGenerator()。
def test_decoded_generator(self): eq = self.assertEqual msg = self._msgobj('msg_07.txt') fp = openfile('msg_17.txt') try: text = fp.read() finally: fp.close() s = StringIO() g = DecodedGenerator(s) g.flatten(msg) eq(s.getvalue(), text)
def test_decoded_generator(self): eq = self.assertEqual msg = self._msgobj('msg_07.txt') with openfile('msg_17.txt') as fp: text = fp.read() s = StringIO() g = DecodedGenerator(s) g.flatten(msg) eq(s.getvalue(), text)
def test_decoded_generator_emits_unicode_body(self): m = email.message_from_bytes(self.latin_bin_msg) out = StringIO() email.generator.DecodedGenerator(out).flatten(m) #DecodedHeader output contains an extra blank line compared #to the input message. RDM: not sure if this is a bug or not, #but it is not specific to the 8bit->7bit conversion. self.assertEqual(out.getvalue(), self.latin_bin_msg.decode('latin-1')+'\n')