def test_custom_message_gets_policy_if_possible_from_file(self): source_file = io.StringIO("Subject: bogus\n\nmsg\n") msg = email.message_from_file(source_file, self.MyMessage, policy=self.MyPolicy) self.assertTrue(isinstance(msg, self.MyMessage)) self.assertIs(msg.check_policy, self.MyPolicy)
def test_message_from_file(self): f = io.StringIO('Subject: test\n\n') with self.assertRaisesRegex(Exception, "^test$"): email.message_from_file(f, policy=self.MyPolicy)
def _msgobj(self, filename): with openfile(filename) as fp: return email.message_from_file(fp, policy=self.policy)