コード例 #1
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_text_invalid_keyword(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain

            Basic text.
            """))
        with self.assertRaises(TypeError):
            raw_data_manager.get_content(m, foo='ignore')
コード例 #2
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_text_invalid_keyword(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain

            Basic text.
            """))
        with self.assertRaises(TypeError):
            raw_data_manager.get_content(m, foo='ignore')
コード例 #3
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_non_text_invalid_keyword(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: image/jpg
            Content-Transfer-Encoding: base64

            Ym9ndXMgZGF0YQ==
            """))
        with self.assertRaises(TypeError):
            raw_data_manager.get_content(m, errors='ignore')
コード例 #4
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_raises_on_multipart(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: multipart/mixed; boundary="==="

            --===
            --===--
            """))
        with self.assertRaises(KeyError):
            raw_data_manager.get_content(m)
コード例 #5
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_raises_on_multipart(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: multipart/mixed; boundary="==="

            --===
            --===--
            """))
        with self.assertRaises(KeyError):
            raw_data_manager.get_content(m)
コード例 #6
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_non_text_invalid_keyword(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: image/jpg
            Content-Transfer-Encoding: base64

            Ym9ndXMgZGF0YQ==
            """))
        with self.assertRaises(TypeError):
            raw_data_manager.get_content(m, errors='ignore')
コード例 #7
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_text_plain_latin1(self):
        m = self._bytes_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset=latin1

            Basìc tëxt.
            """).encode('latin1'))
        self.assertEqual(raw_data_manager.get_content(m), "Basìc tëxt.\n")
コード例 #8
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_text_plain(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain

            Basic text.
            """))
        self.assertEqual(raw_data_manager.get_content(m), "Basic text.\n")
コード例 #9
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_text_plain_latin1(self):
        m = self._bytes_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset=latin1

            Basìc tëxt.
            """).encode('latin1'))
        self.assertEqual(raw_data_manager.get_content(m), "Basìc tëxt.\n")
コード例 #10
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_text_plain(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain

            Basic text.
            """))
        self.assertEqual(raw_data_manager.get_content(m), "Basic text.\n")
コード例 #11
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_text_plain_latin1_quoted_printable(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset="latin-1"
            Content-Transfer-Encoding: quoted-printable

            Bas=ECc t=EBxt.
            """))
        self.assertEqual(raw_data_manager.get_content(m), "Basìc tëxt.\n")
コード例 #12
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_text_html(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/html

            <p>Basic text.</p>
            """))
        self.assertEqual(raw_data_manager.get_content(m),
                         "<p>Basic text.</p>\n")
コード例 #13
0
    def test_get_text_plain_utf8_base64_recoverable_bad_CTE_data(self):
        m = self._bytes_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset="utf8"
            Content-Transfer-Encoding: base64

            QmFzw6xjIHTDq3h0Lgo""").encode('ascii') + b'\xFF=\n')
        self.assertEqual(raw_data_manager.get_content(m, errors='ignore'),
                         "Basìc tëxt.\n")
コード例 #14
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_text_html(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/html

            <p>Basic text.</p>
            """))
        self.assertEqual(raw_data_manager.get_content(m),
                         "<p>Basic text.</p>\n")
コード例 #15
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_text_plain_utf8_base64(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset="utf8"
            Content-Transfer-Encoding: base64

            QmFzw6xjIHTDq3h0Lgo=
            """))
        self.assertEqual(raw_data_manager.get_content(m), "Basìc tëxt.\n")
コード例 #16
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_text_plain_bad_utf8_quoted_printable(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset="utf8"
            Content-Transfer-Encoding: quoted-printable

            Bas=c3=acc t=c3=abxt=fd.
            """))
        self.assertEqual(raw_data_manager.get_content(m), "Basìc tëxt�.\n")
コード例 #17
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_text_plain_latin1_quoted_printable(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset="latin-1"
            Content-Transfer-Encoding: quoted-printable

            Bas=ECc t=EBxt.
            """))
        self.assertEqual(raw_data_manager.get_content(m), "Basìc tëxt.\n")
コード例 #18
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_text_plain_bad_utf8_quoted_printable(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset="utf8"
            Content-Transfer-Encoding: quoted-printable

            Bas=c3=acc t=c3=abxt=fd.
            """))
        self.assertEqual(raw_data_manager.get_content(m), "Basìc tëxt�.\n")
コード例 #19
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_text_plain_utf8_base64(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset="utf8"
            Content-Transfer-Encoding: base64

            QmFzw6xjIHTDq3h0Lgo=
            """))
        self.assertEqual(raw_data_manager.get_content(m), "Basìc tëxt.\n")
コード例 #20
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_text_plain_utf8_base64_recoverable_bad_CTE_data(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: text/plain; charset="utf8"
            Content-Transfer-Encoding: base64

            QmFzw6xjIHTDq3h0Lgo\xFF=
            """))
        self.assertEqual(raw_data_manager.get_content(m, errors='ignore'),
                         "Basìc tëxt.\n")
コード例 #21
0
    def test_get_message_rfc822_and_external_body(self):
        template = textwrap.dedent("""\
            Content-Type: message/{}

            To: [email protected]
            From: [email protected]
            Subject: example

            an example message
            """)
        for subtype in 'rfc822 external-body'.split():
            with self.subTest(subtype=subtype):
                m = self._str_msg(template.format(subtype))
                sub_msg = raw_data_manager.get_content(m)
                self.assertIsInstance(sub_msg, self.message)
                self.assertEqual(raw_data_manager.get_content(sub_msg),
                                 "an example message\n")
                self.assertEqual(sub_msg['to'], '*****@*****.**')
                self.assertEqual(sub_msg['from'].addresses[0].username, 'bar')
コード例 #22
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_message_rfc822_and_external_body(self):
        template = textwrap.dedent("""\
            Content-Type: message/{}

            To: [email protected]
            From: [email protected]
            Subject: example

            an example message
            """)
        for subtype in 'rfc822 external-body'.split():
            with self.subTest(subtype=subtype):
                m = self._str_msg(template.format(subtype))
                sub_msg = raw_data_manager.get_content(m)
                self.assertIsInstance(sub_msg, self.message)
                self.assertEqual(raw_data_manager.get_content(sub_msg),
                                 "an example message\n")
                self.assertEqual(sub_msg['to'], '*****@*****.**')
                self.assertEqual(sub_msg['from'].addresses[0].username, 'bar')
コード例 #23
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_non_text(self):
        template = textwrap.dedent("""\
            Content-Type: {}
            Content-Transfer-Encoding: base64

            Ym9ndXMgZGF0YQ==
            """)
        for maintype in 'audio image video application'.split():
            with self.subTest(maintype=maintype):
                m = self._str_msg(template.format(maintype+'/foo'))
                self.assertEqual(raw_data_manager.get_content(m), b"bogus data")
コード例 #24
0
ファイル: test_contentmanager.py プロジェクト: za/cpython
    def test_get_message_non_rfc822_or_external_body_yields_bytes(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: message/partial

            To: [email protected]
            From: [email protected]
            Subject: example

            The real body is in another message.
            """))
        self.assertEqual(raw_data_manager.get_content(m)[:10], b'To: foo@ex')
コード例 #25
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_non_text(self):
        template = textwrap.dedent("""\
            Content-Type: {}
            Content-Transfer-Encoding: base64

            Ym9ndXMgZGF0YQ==
            """)
        for maintype in 'audio image video application'.split():
            with self.subTest(maintype=maintype):
                m = self._str_msg(template.format(maintype+'/foo'))
                self.assertEqual(raw_data_manager.get_content(m), b"bogus data")
コード例 #26
0
ファイル: hooks.py プロジェクト: ulrikdem/dotfiles
def open_browser(ui):
    body = ui.current_buffer.get_selected_message().get_email().get_body(
        ('html', ))
    if not body:
        ui.notify('no html part', priority='error')
        return
    with NamedTemporaryFile('w', prefix='alot.', suffix='.html',
                            delete=False) as file:
        file.write(raw_data_manager.get_content(body))
        url = 'file://' + file.name
    Popen(['luakit', url], stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL)
コード例 #27
0
ファイル: test_contentmanager.py プロジェクト: 1st1/cpython
    def test_get_message_non_rfc822_or_external_body_yields_bytes(self):
        m = self._str_msg(textwrap.dedent("""\
            Content-Type: message/partial

            To: [email protected]
            From: [email protected]
            Subject: example

            The real body is in another message.
            """))
        self.assertEqual(raw_data_manager.get_content(m)[:10], b'To: foo@ex')
コード例 #28
0
ファイル: mail.py プロジェクト: th-certbund/intelmq-mailgen
 def get_content(self, msg, *args, **kw):
     raw_data_manager.get_content(msg, *args, **kw)
コード例 #29
0
ファイル: mail.py プロジェクト: Intevation/intelmq-mailgen
 def get_content(self, msg, *args, **kw):
     return raw_data_manager.get_content(msg, *args, **kw)