8000 [3.12] gh-120048: Make `test_imaplib` faster (GH-120050) by miss-islington · Pull Request #120070 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.12] gh-120048: Make test_imaplib faster 8000 (GH-120050) #120070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions Lib/test/test_imaplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,18 +458,14 @@ def test_simple_with_statement(self):
with self.imap_class(*server.server_address):
pass

@requires_resource('walltime')
def test_imaplib_timeout_test(self):
_, server = self._setup(SimpleIMAPHandler)
addr = server.server_address[1]
client = self.imap_class("localhost", addr, timeout=None)
self.assertEqual(client.sock.timeout, None)
client.shutdown()
client = self.imap_class("localhost", addr, timeout=support.LOOPBACK_TIMEOUT)
self.assertEqual(client.sock.timeout, support.LOOPBACK_TIMEOUT)
client.shutdown()
_, server = self._setup(SimpleIMAPHandler, connect=False)
with self.imap_class(*server.server_address, timeout=None) as client:
self.assertEqual(client.sock.timeout, None)
with self.imap_class(*server.server_address, timeout=support.LOOPBACK_TIMEOUT) as client:
self.assertEqual(client.sock.timeout, support.LOOPBACK_TIMEOUT)
with self.assertRaises(ValueError):
client = self.imap_class("localhost", addr, timeout=0)
self.imap_class(*server.server_address, timeout=0)

def test_imaplib_timeout_functionality_test(self):
class TimeoutHandler(SimpleIMAPHandler):
Expand Down Expand Up @@ -552,7 +548,6 @@ class NewIMAPSSLTests(NewIMAPTestsMixin, unittest.TestCase):
imap_class = IMAP4_SSL
server_class = SecureTCPServer

@requires_resource('walltime')
def test_ssl_raises(self):
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
self.assertEqual(ssl_context.verify_mode, ssl.CERT_REQUIRED)
Expand All @@ -566,17 +561,16 @@ def test_ssl_raises(self):
CERTIFICATE_VERIFY_FAILED # AWS-LC
)""", re.X)
with self.assertRaisesRegex(ssl.CertificateError, regex):
_, server = self._setup(SimpleIMAPHandler)
_, server = self._setup(SimpleIMAPHandler, connect=False)
client = self.imap_class(*server.server_address,
ssl_context=ssl_context)
client.shutdown()

@requires_resource('walltime')
def test_ssl_verified(self):
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_verify_locations(CAFILE)

_, server = self._setup(SimpleIMAPHandler)
_, server = self._setup(SimpleIMAPHandler, connect=False)
client = self.imap_class("localhost", server.server_address[1],
ssl_context=ssl_context)
client.shutdown()
Expand Down
Loading
0