Commit 088a874c authored by R David Murray's avatar R David Murray

Make test_mailbox runnable via python -m unittest.

parent ceeb47d0
......@@ -20,7 +20,7 @@ except ImportError:
# Silence Py3k warning
rfc822 = test_support.import_module('rfc822', deprecated=True)
class TestBase(unittest.TestCase):
class TestBase:
def _check_sample(self, msg):
# Inspect a mailbox.Message representation of the sample message
......@@ -429,7 +429,7 @@ class TestMailbox(TestBase):
return self._path + '.lock'
class TestMailboxSuperclass(TestBase):
class TestMailboxSuperclass(TestBase, unittest.TestCase):
def test_notimplemented(self):
# Test that all Mailbox methods raise NotImplementedException.
......@@ -464,7 +464,7 @@ class TestMailboxSuperclass(TestBase):
self.assertRaises(NotImplementedError, lambda: box.close())
class TestMaildir(TestMailbox):
class TestMaildir(TestMailbox, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.Maildir(path, factory)
......@@ -914,7 +914,7 @@ class _TestMboxMMDF(TestMailbox):
self._box.close()
class TestMbox(_TestMboxMMDF):
class TestMbox(_TestMboxMMDF, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.mbox(path, factory)
......@@ -937,12 +937,12 @@ class TestMbox(_TestMboxMMDF):
perms = st.st_mode
self.assertFalse((perms & 0111)) # Execute bits should all be off.
class TestMMDF(_TestMboxMMDF):
class TestMMDF(_TestMboxMMDF, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.MMDF(path, factory)
class TestMH(TestMailbox):
class TestMH(TestMailbox, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.MH(path, factory)
......@@ -1074,7 +1074,7 @@ class TestMH(TestMailbox):
return os.path.join(self._path, '.mh_sequences.lock')
class TestBabyl(TestMailbox):
class TestBabyl(TestMailbox, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.Babyl(path, factory)
......@@ -1103,7 +1103,7 @@ class TestBabyl(TestMailbox):
self.assertEqual(set(self._box.get_labels()), set(['blah']))
class TestMessage(TestBase):
class TestMessage(TestBase, unittest.TestCase):
_factory = mailbox.Message # Overridden by subclasses to reuse tests
......@@ -1174,7 +1174,7 @@ class TestMessage(TestBase):
pass
class TestMaildirMessage(TestMessage):
class TestMaildirMessage(TestMessage, unittest.TestCase):
_factory = mailbox.MaildirMessage
......@@ -1249,7 +1249,7 @@ class TestMaildirMessage(TestMessage):
self._check_sample(msg)
class _TestMboxMMDFMessage(TestMessage):
class _TestMboxMMDFMessage:
_factory = mailbox._mboxMMDFMessage
......@@ -1296,12 +1296,12 @@ class _TestMboxMMDFMessage(TestMessage):
r"\d{2} \d{4}", msg.get_from()))
class TestMboxMessage(_TestMboxMMDFMessage):
class TestMboxMessage(_TestMboxMMDFMessage, TestMessage):
_factory = mailbox.mboxMessage
class TestMHMessage(TestMessage):
class TestMHMessage(TestMessage, unittest.TestCase):
_factory = mailbox.MHMessage
......@@ -1332,7 +1332,7 @@ class TestMHMessage(TestMessage):
self.assertEqual(msg.get_sequences(), ['foobar', 'replied'])
class TestBabylMessage(TestMessage):
class TestBabylMessage(TestMessage, unittest.TestCase):
_factory = mailbox.BabylMessage
......@@ -1387,12 +1387,12 @@ class TestBabylMessage(TestMessage):
self.assertEqual(visible[header], msg[header])
class TestMMDFMessage(_TestMboxMMDFMessage):
class TestMMDFMessage(_TestMboxMMDFMessage, TestMessage):
_factory = mailbox.MMDFMessage
class TestMessageConversion(TestBase):
class TestMessageConversion(TestBase, unittest.TestCase):
def test_plain_to_x(self):
# Convert Message to all formats
......@@ -1715,7 +1715,7 @@ class TestProxyFileBase(TestBase):
proxy.close()
class TestProxyFile(TestProxyFileBase):
class TestProxyFile(TestProxyFileBase, unittest.TestCase):
def setUp(self):
self._path = test_support.TESTFN
......@@ -1764,7 +1764,7 @@ class TestProxyFile(TestProxyFileBase):
self._test_close(mailbox._ProxyFile(self._file))
class TestPartialFile(TestProxyFileBase):
class TestPartialFile(TestProxyFileBase, unittest.TestCase):
def setUp(self):
self._path = test_support.TESTFN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment