mirror of https://github.com/python/cpython
Merge: Make test_mailbox runnable via python -m unittest.
This commit is contained in:
commit
f998810deb
|
@ -20,7 +20,7 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestBase(unittest.TestCase):
|
class TestBase:
|
||||||
|
|
||||||
def _check_sample(self, msg):
|
def _check_sample(self, msg):
|
||||||
# Inspect a mailbox.Message representation of the sample message
|
# Inspect a mailbox.Message representation of the sample message
|
||||||
|
@ -545,7 +545,7 @@ class TestMailbox(TestBase):
|
||||||
return self._path + '.lock'
|
return self._path + '.lock'
|
||||||
|
|
||||||
|
|
||||||
class TestMailboxSuperclass(TestBase):
|
class TestMailboxSuperclass(TestBase, unittest.TestCase):
|
||||||
|
|
||||||
def test_notimplemented(self):
|
def test_notimplemented(self):
|
||||||
# Test that all Mailbox methods raise NotImplementedException.
|
# Test that all Mailbox methods raise NotImplementedException.
|
||||||
|
@ -581,7 +581,7 @@ class TestMailboxSuperclass(TestBase):
|
||||||
self.assertRaises(NotImplementedError, lambda: box.close())
|
self.assertRaises(NotImplementedError, lambda: box.close())
|
||||||
|
|
||||||
|
|
||||||
class TestMaildir(TestMailbox):
|
class TestMaildir(TestMailbox, unittest.TestCase):
|
||||||
|
|
||||||
_factory = lambda self, path, factory=None: mailbox.Maildir(path, factory)
|
_factory = lambda self, path, factory=None: mailbox.Maildir(path, factory)
|
||||||
|
|
||||||
|
@ -1042,7 +1042,7 @@ class _TestMboxMMDF(TestMailbox):
|
||||||
self._box.close()
|
self._box.close()
|
||||||
|
|
||||||
|
|
||||||
class TestMbox(_TestMboxMMDF):
|
class TestMbox(_TestMboxMMDF, unittest.TestCase):
|
||||||
|
|
||||||
_factory = lambda self, path, factory=None: mailbox.mbox(path, factory)
|
_factory = lambda self, path, factory=None: mailbox.mbox(path, factory)
|
||||||
|
|
||||||
|
@ -1065,12 +1065,12 @@ class TestMbox(_TestMboxMMDF):
|
||||||
perms = st.st_mode
|
perms = st.st_mode
|
||||||
self.assertFalse((perms & 0o111)) # Execute bits should all be off.
|
self.assertFalse((perms & 0o111)) # Execute bits should all be off.
|
||||||
|
|
||||||
class TestMMDF(_TestMboxMMDF):
|
class TestMMDF(_TestMboxMMDF, unittest.TestCase):
|
||||||
|
|
||||||
_factory = lambda self, path, factory=None: mailbox.MMDF(path, factory)
|
_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)
|
_factory = lambda self, path, factory=None: mailbox.MH(path, factory)
|
||||||
|
|
||||||
|
@ -1205,7 +1205,7 @@ class TestMH(TestMailbox):
|
||||||
return os.path.join(self._path, '.mh_sequences.lock')
|
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)
|
_factory = lambda self, path, factory=None: mailbox.Babyl(path, factory)
|
||||||
|
|
||||||
|
@ -1270,7 +1270,7 @@ class TestFakeMailBox(unittest.TestCase):
|
||||||
self.assertTrue(box.files[i].closed)
|
self.assertTrue(box.files[i].closed)
|
||||||
|
|
||||||
|
|
||||||
class TestMessage(TestBase):
|
class TestMessage(TestBase, unittest.TestCase):
|
||||||
|
|
||||||
_factory = mailbox.Message # Overridden by subclasses to reuse tests
|
_factory = mailbox.Message # Overridden by subclasses to reuse tests
|
||||||
|
|
||||||
|
@ -1350,7 +1350,7 @@ class TestMessage(TestBase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestMaildirMessage(TestMessage):
|
class TestMaildirMessage(TestMessage, unittest.TestCase):
|
||||||
|
|
||||||
_factory = mailbox.MaildirMessage
|
_factory = mailbox.MaildirMessage
|
||||||
|
|
||||||
|
@ -1424,7 +1424,7 @@ class TestMaildirMessage(TestMessage):
|
||||||
self._check_sample(msg)
|
self._check_sample(msg)
|
||||||
|
|
||||||
|
|
||||||
class _TestMboxMMDFMessage(TestMessage):
|
class _TestMboxMMDFMessage:
|
||||||
|
|
||||||
_factory = mailbox._mboxMMDFMessage
|
_factory = mailbox._mboxMMDFMessage
|
||||||
|
|
||||||
|
@ -1471,12 +1471,12 @@ class _TestMboxMMDFMessage(TestMessage):
|
||||||
r"\d{2} \d{4}", msg.get_from()) is not None)
|
r"\d{2} \d{4}", msg.get_from()) is not None)
|
||||||
|
|
||||||
|
|
||||||
class TestMboxMessage(_TestMboxMMDFMessage):
|
class TestMboxMessage(_TestMboxMMDFMessage, TestMessage):
|
||||||
|
|
||||||
_factory = mailbox.mboxMessage
|
_factory = mailbox.mboxMessage
|
||||||
|
|
||||||
|
|
||||||
class TestMHMessage(TestMessage):
|
class TestMHMessage(TestMessage, unittest.TestCase):
|
||||||
|
|
||||||
_factory = mailbox.MHMessage
|
_factory = mailbox.MHMessage
|
||||||
|
|
||||||
|
@ -1507,7 +1507,7 @@ class TestMHMessage(TestMessage):
|
||||||
self.assertEqual(msg.get_sequences(), ['foobar', 'replied'])
|
self.assertEqual(msg.get_sequences(), ['foobar', 'replied'])
|
||||||
|
|
||||||
|
|
||||||
class TestBabylMessage(TestMessage):
|
class TestBabylMessage(TestMessage, unittest.TestCase):
|
||||||
|
|
||||||
_factory = mailbox.BabylMessage
|
_factory = mailbox.BabylMessage
|
||||||
|
|
||||||
|
@ -1562,12 +1562,12 @@ class TestBabylMessage(TestMessage):
|
||||||
self.assertEqual(visible[header], msg[header])
|
self.assertEqual(visible[header], msg[header])
|
||||||
|
|
||||||
|
|
||||||
class TestMMDFMessage(_TestMboxMMDFMessage):
|
class TestMMDFMessage(_TestMboxMMDFMessage, TestMessage):
|
||||||
|
|
||||||
_factory = mailbox.MMDFMessage
|
_factory = mailbox.MMDFMessage
|
||||||
|
|
||||||
|
|
||||||
class TestMessageConversion(TestBase):
|
class TestMessageConversion(TestBase, unittest.TestCase):
|
||||||
|
|
||||||
def test_plain_to_x(self):
|
def test_plain_to_x(self):
|
||||||
# Convert Message to all formats
|
# Convert Message to all formats
|
||||||
|
@ -1908,7 +1908,7 @@ class TestProxyFileBase(TestBase):
|
||||||
self.assertTrue(proxy.closed)
|
self.assertTrue(proxy.closed)
|
||||||
|
|
||||||
|
|
||||||
class TestProxyFile(TestProxyFileBase):
|
class TestProxyFile(TestProxyFileBase, unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._path = support.TESTFN
|
self._path = support.TESTFN
|
||||||
|
@ -1957,7 +1957,7 @@ class TestProxyFile(TestProxyFileBase):
|
||||||
self._test_close(mailbox._ProxyFile(self._file))
|
self._test_close(mailbox._ProxyFile(self._file))
|
||||||
|
|
||||||
|
|
||||||
class TestPartialFile(TestProxyFileBase):
|
class TestPartialFile(TestProxyFileBase, unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._path = support.TESTFN
|
self._path = support.TESTFN
|
||||||
|
|
Loading…
Reference in New Issue