Skip to content

Commit b18563d

Browse files
authored
bpo-30231: Remove skipped test_imaplib tests (#1419)
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.
1 parent 778b484 commit b18563d

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

Lib/test/test_imaplib.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import calendar
1313

1414
from test.support import (reap_threads, verbose, transient_internet,
15-
run_with_tz, run_with_locale)
15+
run_with_tz, run_with_locale, cpython_only)
1616
import unittest
1717
from unittest import mock
1818
from datetime import datetime, timezone, timedelta
@@ -503,6 +503,15 @@ def test_ssl_verified(self):
503503
ssl_context=ssl_context)
504504
client.shutdown()
505505

506+
# Mock the private method _connect(), so mark the test as specific
507+
# to CPython stdlib
508+
@cpython_only
509+
def test_certfile_arg_warn(self):
510+
with support.check_warnings(('', DeprecationWarning)):
511+
with mock.patch.object(self.imap_class, 'open'):
512+
with mock.patch.object(self.imap_class, '_connect'):
513+
self.imap_class('localhost', 143, certfile=CERTFILE)
514+
506515
class ThreadedNetworkedTests(unittest.TestCase):
507516
server_class = socketserver.TCPServer
508517
imap_class = imaplib.IMAP4
@@ -965,25 +974,6 @@ def test_logincapa(self):
965974
_server = self.imap_class(self.host, self.port)
966975
self.check_logincapa(_server)
967976

968-
@unittest.skipIf(True,
969-
"bpo-30175: FIXME: cyrus.andrew.cmu.edu doesn't accept "
970-
"our randomly generated client x509 certificate anymore")
971-
def test_logincapa_with_client_certfile(self):
972-
with transient_internet(self.host):
973-
with support.check_warnings(('', DeprecationWarning)):
974-
_server = self.imap_class(self.host, self.port,
975-
certfile=CERTFILE)
976-
self.check_logincapa(_server)
977-
978-
@unittest.skipIf(True,
979-
"bpo-30175: FIXME: cyrus.andrew.cmu.edu doesn't accept "
980-
"our randomly generated client x509 certificate anymore")
981-
def test_logincapa_with_client_ssl_context(self):
982-
with transient_internet(self.host):
983-
_server = self.imap_class(
984-
self.host, self.port, ssl_context=self.create_ssl_context())
985-
self.check_logincapa(_server)
986-
987977
def test_logout(self):
988978
with transient_internet(self.host):
989979
_server = self.imap_class(self.host, self.port)

0 commit comments

Comments
 (0)