Skip to content

Commit 8a39af9

Browse files
authored
bpo-30231: Remove skipped test_imaplib tests (#1419) (#2192)
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. (cherry picked from commit b18563d)
1 parent 6628006 commit 8a39af9

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
@@ -13,7 +13,7 @@
1313
import inspect
1414

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

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

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

0 commit comments

Comments
 (0)