Thanks for the patch. Comments:
- the keyfile / certfile pair and the context parameter should be mutually exclusive (see e.g. the POP3_SSL constructor in Lib/poplib.py)
- I don't think the remote test server used in test_imaplib supports client certificates, it probably just ignores them; that said, it's better than nothing
- you have a misindented line in test_logincapa
- since we're using a remote, third-party test server, it may be better not to do any spurious connects (in the current patch, a first connection is established in the setUp() and then ignored since another one is established in the test body)
- you need to update the documentation in Doc/library/imaplib.rst |