Skip to content

Commit 348e256

Browse files
committed
update
1 parent fd70932 commit 348e256

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

Lib/test/test_httpservers.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,31 +1537,31 @@ def test_server_test_ipv4(self, _):
15371537
self.assertEqual(mock_server.address_family, socket.AF_INET)
15381538

15391539
class CommandLineTestCase(unittest.TestCase):
1540+
default_port = 8000
1541+
default_bind = None
1542+
default_protocol = 'HTTP/1.0'
1543+
default_handler = SimpleHTTPRequestHandler
1544+
default_server = unittest.mock.ANY
1545+
tls_cert = certdata_file('ssl_cert.pem')
1546+
tls_key = certdata_file('ssl_key.pem')
1547+
tls_password = 'somepass'
1548+
args = {
1549+
'HandlerClass': default_handler,
1550+
'ServerClass': default_server,
1551+
'protocol': default_protocol,
1552+
'port': default_port,
1553+
'bind': default_bind,
1554+
'tls_cert': None,
1555+
'tls_key': None,
1556+
'tls_password': None,
1557+
}
1558+
15401559
def setUp(self):
15411560
super().setUp()
1542-
self.default_port = 8000
1543-
self.default_bind = None
1544-
self.default_protocol = 'HTTP/1.0'
1545-
self.default_handler = SimpleHTTPRequestHandler
1546-
self.default_server = unittest.mock.ANY
1547-
self.tls_cert = certdata_file('ssl_cert.pem')
1548-
self.tls_key = certdata_file('ssl_key.pem')
1549-
self.tls_password = 'somepass'
1550-
tls_password_file_object = \
1551-
tempfile.NamedTemporaryFile(mode='w+', delete=False)
1552-
tls_password_file_object.write(self.tls_password)
1553-
self.tls_password_file = tls_password_file_object.name
1554-
tls_password_file_object.close()
1555-
self.args = {
1556-
'HandlerClass': self.default_handler,
1557-
'ServerClass': self.default_server,
1558-
'protocol': self.default_protocol,
1559-
'port': self.default_port,
1560-
'bind': self.default_bind,
1561-
'tls_cert': None,
1562-
'tls_key': None,
1563-
'tls_password': None,
1564-
}
1561+
self.tls_password_file = tempfile.mktemp()
1562+
with open(self.tls_password_file, 'wb') as f:
1563+
f.write(self.tls_password.encode())
1564+
self.addCleanup(os_helper.unlink, self.tls_password_file)
15651565

15661566
def tearDown(self):
15671567
if os.path.exists(self.tls_password_file):

0 commit comments

Comments
 (0)