bpo-37795: Capture DeprecationWarnings in the test suite (GH-15184)
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 9148169..656932f 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -7,6 +7,7 @@
import re
import socket
import threading
+import warnings
import unittest
TestCase = unittest.TestCase
@@ -1759,8 +1760,11 @@
self.assertIs(h._context, context)
self.assertFalse(h._context.post_handshake_auth)
- h = client.HTTPSConnection('localhost', 443, context=context,
- cert_file=CERT_localhost)
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore', 'key_file, cert_file and check_hostname are deprecated',
+ DeprecationWarning)
+ h = client.HTTPSConnection('localhost', 443, context=context,
+ cert_file=CERT_localhost)
self.assertTrue(h._context.post_handshake_auth)