From e3dca064f530a3b6aa156e2f6f97e0b8d5a5ad36 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 3 May 2017 09:08:13 +0200 Subject: [PATCH] bpo-30231: Remove skipped test_imaplib tests The public cyrus.andrew.cmu.edu IMAP server (port 993) doesn't accept TLS connection using our self-signed x509 certificate. Remove the two tests which are already skipped. Write a new test_certfile_arg_warn() unit test for the certfile deprecation warning. --- Lib/test/test_imaplib.py | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index a33fb714fe7bff..7c124380b14ee3 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -12,7 +12,7 @@ import calendar from test.support import (reap_threads, verbose, transient_internet, - run_with_tz, run_with_locale) + run_with_tz, run_with_locale, cpython_only) import unittest from unittest import mock from datetime import datetime, timezone, timedelta @@ -503,6 +503,15 @@ def test_ssl_verified(self): ssl_context=ssl_context) client.shutdown() + # Mock the private method _connect(), so mark the test as specific + # to CPython stdlib + @cpython_only + def test_certfile_arg_warn(self): + with support.check_warnings(('', DeprecationWarning)): + with mock.patch.object(self.imap_class, 'open'): + with mock.patch.object(self.imap_class, '_connect'): + self.imap_class('localhost', 143, certfile=CERTFILE) + class ThreadedNetworkedTests(unittest.TestCase): server_class = socketserver.TCPServer imap_class = imaplib.IMAP4 @@ -965,25 +974,6 @@ def test_logincapa(self): _server = self.imap_class(self.host, self.port) self.check_logincapa(_server) - @unittest.skipIf(True, - "bpo-30175: FIXME: cyrus.andrew.cmu.edu doesn't accept " - "our randomly generated client x509 certificate anymore") - def test_logincapa_with_client_certfile(self): - with transient_internet(self.host): - with support.check_warnings(('', DeprecationWarning)): - _server = self.imap_class(self.host, self.port, - certfile=CERTFILE) - self.check_logincapa(_server) - - @unittest.skipIf(True, - "bpo-30175: FIXME: cyrus.andrew.cmu.edu doesn't accept " - "our randomly generated client x509 certificate anymore") - def test_logincapa_with_client_ssl_context(self): - with transient_internet(self.host): - _server = self.imap_class( - self.host, self.port, ssl_context=self.create_ssl_context()) - self.check_logincapa(_server) - def test_logout(self): with transient_internet(self.host): _server = self.imap_class(self.host, self.port)