1313TestCase = unittest .TestCase
1414
1515from test import support
16+ from test .support import os_helper
1617from test .support import socket_helper
18+ from test .support import warnings_helper
19+
1720
1821here = os .path .dirname (__file__ )
1922# Self-signed cert file for 'localhost'
@@ -1766,14 +1769,14 @@ def test_local_bad_hostname(self):
17661769 with self .assertRaises (ssl .CertificateError ):
17671770 h .request ('GET' , '/' )
17681771 # Same with explicit check_hostname=True
1769- with support .check_warnings (('' , DeprecationWarning )):
1772+ with warnings_helper .check_warnings (('' , DeprecationWarning )):
17701773 h = client .HTTPSConnection ('localhost' , server .port ,
17711774 context = context , check_hostname = True )
17721775 with self .assertRaises (ssl .CertificateError ):
17731776 h .request ('GET' , '/' )
17741777 # With check_hostname=False, the mismatching is ignored
17751778 context .check_hostname = False
1776- with support .check_warnings (('' , DeprecationWarning )):
1779+ with warnings_helper .check_warnings (('' , DeprecationWarning )):
17771780 h = client .HTTPSConnection ('localhost' , server .port ,
17781781 context = context , check_hostname = False )
17791782 h .request ('GET' , '/nonexistent' )
@@ -1792,7 +1795,7 @@ def test_local_bad_hostname(self):
17921795 h .close ()
17931796 # Passing check_hostname to HTTPSConnection should override the
17941797 # context's setting.
1795- with support .check_warnings (('' , DeprecationWarning )):
1798+ with warnings_helper .check_warnings (('' , DeprecationWarning )):
17961799 h = client .HTTPSConnection ('localhost' , server .port ,
17971800 context = context , check_hostname = True )
17981801 with self .assertRaises (ssl .CertificateError ):
@@ -1908,10 +1911,10 @@ def test_bytes_body(self):
19081911 self .assertEqual (b'body\xc1 ' , f .read ())
19091912
19101913 def test_text_file_body (self ):
1911- self .addCleanup (support .unlink , support .TESTFN )
1912- with open (support .TESTFN , "w" ) as f :
1914+ self .addCleanup (os_helper .unlink , os_helper .TESTFN )
1915+ with open (os_helper .TESTFN , "w" ) as f :
19131916 f .write ("body" )
1914- with open (support .TESTFN ) as f :
1917+ with open (os_helper .TESTFN ) as f :
19151918 self .conn .request ("PUT" , "/url" , f )
19161919 message , f = self .get_headers_and_fp ()
19171920 self .assertEqual ("text/plain" , message .get_content_type ())
@@ -1923,10 +1926,10 @@ def test_text_file_body(self):
19231926 self .assertEqual (b'4\r \n body\r \n 0\r \n \r \n ' , f .read ())
19241927
19251928 def test_binary_file_body (self ):
1926- self .addCleanup (support .unlink , support .TESTFN )
1927- with open (support .TESTFN , "wb" ) as f :
1929+ self .addCleanup (os_helper .unlink , os_helper .TESTFN )
1930+ with open (os_helper .TESTFN , "wb" ) as f :
19281931 f .write (b"body\xc1 " )
1929- with open (support .TESTFN , "rb" ) as f :
1932+ with open (os_helper .TESTFN , "rb" ) as f :
19301933 self .conn .request ("PUT" , "/url" , f )
19311934 message , f = self .get_headers_and_fp ()
19321935 self .assertEqual ("text/plain" , message .get_content_type ())
0 commit comments