summaryrefslogtreecommitdiff
path: root/Lib/test/test_httpservers.py
diff options
context:
space:
mode:
authorLisa Roach <lisaroach14@gmail.com>2018-11-26 10:43:38 -0800
committerGitHub <noreply@github.com>2018-11-26 10:43:38 -0800
commit433433fa6d55091600ce88dd19206b3902e0a87d (patch)
tree568dab8c1adcc3e954f012b9b4ae13ac2f5578f6 /Lib/test/test_httpservers.py
parent75e4699b31d1d88abad097ad13466c5c07711324 (diff)
downloadcpython-git-433433fa6d55091600ce88dd19206b3902e0a87d.tar.gz
Adds IPv6 support when invoking http.server directly. (GH-10595)
Diffstat (limited to 'Lib/test/test_httpservers.py')
-rw-r--r--Lib/test/test_httpservers.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index cc829a522b..3d8e0af8b4 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -9,6 +9,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer, \
from http import server, HTTPStatus
import os
+import socket
import sys
import re
import base64
@@ -1116,6 +1117,24 @@ class MiscTestCase(unittest.TestCase):
self.assertCountEqual(server.__all__, expected)
+class ScriptTestCase(unittest.TestCase):
+ @mock.patch('builtins.print')
+ def test_server_test_ipv6(self, _):
+ mock_server = mock.MagicMock()
+ server.test(ServerClass=mock_server, bind="::")
+ self.assertEqual(mock_server.address_family, socket.AF_INET6)
+
+ mock_server.reset_mock()
+ server.test(ServerClass=mock_server,
+ bind="2001:0db8:85a3:0000:0000:8a2e:0370:7334")
+ self.assertEqual(mock_server.address_family, socket.AF_INET6)
+
+ mock_server.reset_mock()
+ server.test(ServerClass=mock_server,
+ bind="::1")
+ self.assertEqual(mock_server.address_family, socket.AF_INET6)
+
+
def test_main(verbose=None):
cwd = os.getcwd()
try:
@@ -1127,6 +1146,7 @@ def test_main(verbose=None):
CGIHTTPServerTestCase,
SimpleHTTPRequestHandlerTestCase,
MiscTestCase,
+ ScriptTestCase
)
finally:
os.chdir(cwd)