diff -r c43362d35d8d Lib/test/test_imaplib.py --- a/Lib/test/test_imaplib.py Fri Jul 04 17:00:25 2014 -0700 +++ b/Lib/test/test_imaplib.py Thu Jul 31 02:45:30 2014 +0200 @@ -22,8 +22,8 @@ else: from ssl import HAS_SNI -CERTFILE = None -CAFILE = None +CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem") +CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem") class TestImaplib(unittest.TestCase): @@ -47,8 +47,6 @@ imaplib.Internaldate2tuple( b'25 (INTERNALDATE "02-Apr-2000 03:30:00 +0000")')) - - def timevalues(self): return [2000000000, 2000000000.0, time.localtime(2000000000), (2033, 5, 18, 5, 33, 20, -1, -1, -1), @@ -75,7 +73,6 @@ if ssl: - class SecureTCPServer(socketserver.TCPServer): def get_request(self): @@ -351,6 +348,12 @@ server_class = SecureTCPServer imap_class = IMAP4_SSL + def setUp(self): + self.assertTrue(os.path.exists(CERTFILE), + msg="Can't read certificate file at '%s'." % CERTFILE) + self.assertTrue(os.path.exists(CAFILE), + msg="Can't read CA file at '%s'." % CAFILE) + @reap_threads @unittest.skipUnless(HAS_SNI, 'No SNI support in ssl module') def test_ssl_verified(self): @@ -479,24 +482,11 @@ def load_tests(*args): - tests = [TestImaplib] - - if support.is_resource_enabled('network'): - if ssl: - global CERTFILE, CAFILE - CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, - "keycert3.pem") - if not os.path.exists(CERTFILE): - raise support.TestFailed("Can't read certificate files!") - CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, - "pycacert.pem") - if not os.path.exists(CAFILE): - raise support.TestFailed("Can't read CA file!") - tests.extend([ - ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, - RemoteIMAPTest, RemoteIMAP_SSLTest, RemoteIMAP_STARTTLSTest, - ]) - + tests = [ + TestImaplib, + ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, + RemoteIMAPTest, RemoteIMAP_SSLTest, RemoteIMAP_STARTTLSTest, + ] return unittest.TestSuite([unittest.makeSuite(test) for test in tests])