Python mailbox.PortableUnixMailbox() Examples

The following are 14 code examples of mailbox.PortableUnixMailbox(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module mailbox , or try the search function .
Example #1
Source File: test_old_mailbox.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        with open(fname) as f:
            for msg in mailbox.PortableUnixMailbox(f,
                                               email.parser.Parser().parse):
                n += 1
                self.assertEqual(msg["subject"], "Simple Test")
                self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        self.assertEqual(n, 1) 
Example #2
Source File: test_mailbox.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        fid = open(fname)
        for msg in mailbox.PortableUnixMailbox(fid,
                                               email.parser.Parser().parse):
            n += 1
            self.assertEqual(msg["subject"], "Simple Test")
            self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        fid.close()
        self.assertEqual(n, 1)

## End: classes from the original module (for backward compatibility). 
Example #3
Source File: test_old_mailbox.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        with open(fname) as f:
            for msg in mailbox.PortableUnixMailbox(f,
                                               email.parser.Parser().parse):
                n += 1
                self.assertEqual(msg["subject"], "Simple Test")
                self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        self.assertEqual(n, 1) 
Example #4
Source File: test_mailbox.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        fid = open(fname)
        for msg in mailbox.PortableUnixMailbox(fid,
                                               email.parser.Parser().parse):
            n += 1
            self.assertEqual(msg["subject"], "Simple Test")
            self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        fid.close()
        self.assertEqual(n, 1)

## End: classes from the original module (for backward compatibility). 
Example #5
Source File: test_old_mailbox.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        with open(fname) as f:
            for msg in mailbox.PortableUnixMailbox(f,
                                               email.parser.Parser().parse):
                n += 1
                self.assertEqual(msg["subject"], "Simple Test")
                self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        self.assertEqual(n, 1) 
Example #6
Source File: test_mailbox.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        fid = open(fname)
        for msg in mailbox.PortableUnixMailbox(fid,
                                               email.parser.Parser().parse):
            n += 1
            self.assertEqual(msg["subject"], "Simple Test")
            self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        fid.close()
        self.assertEqual(n, 1)

## End: classes from the original module (for backward compatibility). 
Example #7
Source File: test_old_mailbox.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        with open(fname) as f:
            for msg in mailbox.PortableUnixMailbox(f,
                                               email.parser.Parser().parse):
                n += 1
                self.assertEqual(msg["subject"], "Simple Test")
                self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        self.assertEqual(n, 1) 
Example #8
Source File: test_mailbox.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        fid = open(fname)
        for msg in mailbox.PortableUnixMailbox(fid,
                                               email.parser.Parser().parse):
            n += 1
            self.assertEqual(msg["subject"], "Simple Test")
            self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        fid.close()
        self.assertEqual(n, 1)

## End: classes from the original module (for backward compatibility). 
Example #9
Source File: test_old_mailbox.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.Parser
        fname = self.createMessage("cur", True)
        n = 0
        with open(fname) as fp:
            for msg in mailbox.PortableUnixMailbox(fp,
                                                   email.Parser.Parser().parse):
                n += 1
                self.assertEqual(msg["subject"], "Simple Test")
                self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        self.assertEqual(n, 1) 
Example #10
Source File: test_mailbox.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.Parser
        fname = self.createMessage("cur", True)
        n = 0
        for msg in mailbox.PortableUnixMailbox(open(fname),
                                               email.Parser.Parser().parse):
            n += 1
            self.assertEqual(msg["subject"], "Simple Test")
            self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        self.assertEqual(n, 1)

## End: classes from the original module (for backward compatibility). 
Example #11
Source File: test_old_mailbox.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.Parser
        fname = self.createMessage("cur", True)
        n = 0
        with open(fname) as fp:
            for msg in mailbox.PortableUnixMailbox(fp,
                                                   email.Parser.Parser().parse):
                n += 1
                self.assertEqual(msg["subject"], "Simple Test")
                self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        self.assertEqual(n, 1) 
Example #12
Source File: test_mailbox.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        fid = open(fname)
        for msg in mailbox.PortableUnixMailbox(fid,
                                               email.parser.Parser().parse):
            n += 1
            self.assertEqual(msg["subject"], "Simple Test")
            self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        fid.close()
        self.assertEqual(n, 1)

## End: classes from the original module (for backward compatibility). 
Example #13
Source File: test_old_mailbox.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.Parser
        fname = self.createMessage("cur", True)
        n = 0
        with open(fname) as fp:
            for msg in mailbox.PortableUnixMailbox(fp,
                                                   email.Parser.Parser().parse):
                n += 1
                self.assertEqual(msg["subject"], "Simple Test")
                self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        self.assertEqual(n, 1) 
Example #14
Source File: test_mailbox.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_unix_mbox(self):
        ### should be better!
        import email.parser
        fname = self.createMessage("cur", True)
        n = 0
        fid = open(fname)
        for msg in mailbox.PortableUnixMailbox(fid,
                                               email.parser.Parser().parse):
            n += 1
            self.assertEqual(msg["subject"], "Simple Test")
            self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
        fid.close()
        self.assertEqual(n, 1)

## End: classes from the original module (for backward compatibility).