我们从Python开源项目中,提取了以下47个代码示例,用于说明如何使用email.errors.MultipartInvariantViolationDefect()。
def close(self): """Parse all remaining data and return the root message object.""" self._input.close() self._call_parse() root = self._pop_message() assert not self._msgstack # Look for final set of defects if root.get_content_maintype() == 'multipart' \ and not root.is_multipart(): root.defects.append(errors.MultipartInvariantViolationDefect()) return root
def test_multipart_no_boundary(self): unless = self.failUnless msg = self._msgobj('msg_25.txt') unless(isinstance(msg.get_payload(), str)) self.assertEqual(len(msg.defects), 2) unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect)) unless(isinstance(msg.defects[1], errors.MultipartInvariantViolationDefect))
def test_lying_multipart(self): unless = self.failUnless msg = self._msgobj('msg_41.txt') unless(hasattr(msg, 'defects')) self.assertEqual(len(msg.defects), 2) unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect)) unless(isinstance(msg.defects[1], errors.MultipartInvariantViolationDefect))
def test_multipart_no_boundary(self): msg = self._msgobj('msg_25.txt') self.assertIsInstance(msg.get_payload(), str) self.assertEqual(len(msg.defects), 2) self.assertIsInstance(msg.defects[0], errors.NoBoundaryInMultipartDefect) self.assertIsInstance(msg.defects[1], errors.MultipartInvariantViolationDefect)
def test_lying_multipart(self): msg = self._msgobj('msg_41.txt') self.assertTrue(hasattr(msg, 'defects')) self.assertEqual(len(msg.defects), 2) self.assertIsInstance(msg.defects[0], errors.NoBoundaryInMultipartDefect) self.assertIsInstance(msg.defects[1], errors.MultipartInvariantViolationDefect)
def test_multipart_no_boundary(self): unless = self.assertTrue msg = self._msgobj('msg_25.txt') unless(isinstance(msg.get_payload(), str)) self.assertEqual(len(msg.defects), 2) unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect)) unless(isinstance(msg.defects[1], errors.MultipartInvariantViolationDefect))
def test_lying_multipart(self): unless = self.assertTrue msg = self._msgobj('msg_41.txt') unless(hasattr(msg, 'defects')) self.assertEqual(len(msg.defects), 2) unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect)) unless(isinstance(msg.defects[1], errors.MultipartInvariantViolationDefect))
def test_lying_multipart(self): unless = self.assertTrue msg = self._msgobj('msg_41.txt') unless(hasattr(msg, 'defects')) self.assertEqual(len(msg.defects), 2) unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect)) unless(isinstance(msg.defects[1], errors.MultipartInvariantViolationDefect)) # test_defect_handling
def test_multipart_no_boundary(self): source = textwrap.dedent("""\ Date: Fri, 6 Apr 2001 09:23:06 -0800 (GMT-0800) From: foobar Subject: broken mail MIME-Version: 1.0 Content-Type: multipart/report; report-type=delivery-status; --JAB03225.986577786/zinfandel.lacita.com One part --JAB03225.986577786/zinfandel.lacita.com Content-Type: message/delivery-status Header: Another part --JAB03225.986577786/zinfandel.lacita.com-- """) with self._raise_point(errors.NoBoundaryInMultipartDefect): msg = self._str_msg(source) if self.raise_expected: return self.assertTrue(isinstance(msg.get_payload(), str)) self.assertEqual(len(self.get_defects(msg)), 2) self.assertTrue(isinstance(self.get_defects(msg)[0], errors.NoBoundaryInMultipartDefect)) self.assertTrue(isinstance(self.get_defects(msg)[1], errors.MultipartInvariantViolationDefect))
def test_lying_multipart(self): msg = self._msgobj('msg_41.txt') self.assertTrue(hasattr(msg, 'defects')) self.assertEqual(len(msg.defects), 2) self.assertIsInstance(msg.defects[0], errors.NoBoundaryInMultipartDefect) self.assertIsInstance(msg.defects[1], errors.MultipartInvariantViolationDefect) # test_defect_handling
def test_multipart_no_boundary(self): source = textwrap.dedent("""\ Date: Fri, 6 Apr 2001 09:23:06 -0800 (GMT-0800) From: foobar Subject: broken mail MIME-Version: 1.0 Content-Type: multipart/report; report-type=delivery-status; --JAB03225.986577786/zinfandel.lacita.com One part --JAB03225.986577786/zinfandel.lacita.com Content-Type: message/delivery-status Header: Another part --JAB03225.986577786/zinfandel.lacita.com-- """) with self._raise_point(errors.NoBoundaryInMultipartDefect): msg = self._str_msg(source) if self.raise_expected: return self.assertIsInstance(msg.get_payload(), str) self.assertEqual(len(self.get_defects(msg)), 2) self.assertIsInstance(self.get_defects(msg)[0], errors.NoBoundaryInMultipartDefect) self.assertIsInstance(self.get_defects(msg)[1], errors.MultipartInvariantViolationDefect)
def close(self): """Parse all remaining data and return the root message object.""" self._input.close() self._call_parse() root = self._pop_message() assert not self._msgstack # Look for final set of defects if root.get_content_maintype() == 'multipart' \ and not root.is_multipart(): defect = errors.MultipartInvariantViolationDefect() self.policy.handle_defect(root, defect) return root