Skip to content

Commit c6b70cf

Browse files
author
Jussi Kukkonen
committed
tests: Remove unused options from simple_server
We never call simple_server with arguments so this is dead code. Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
1 parent b2704a5 commit c6b70cf

File tree

1 file changed

+2
-50
lines changed

1 file changed

+2
-50
lines changed

tests/simple_server.py

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,16 @@
33
# Copyright 2012 - 2017, New York University and the TUF contributors
44
# SPDX-License-Identifier: MIT OR Apache-2.0
55

6-
"""
7-
<Program>
8-
simple_server.py
9-
10-
<Author>
11-
Konstantin Andrianov.
12-
13-
<Started>
14-
February 15, 2012.
15-
16-
<Copyright>
17-
See LICENSE-MIT or LICENSE for licensing information.
18-
19-
<Purpose>
20-
This is a basic server that was designed to be used in conjunction with
21-
test_download.py to test download.py module.
22-
23-
<Reference>
24-
SimpleHTTPServer:
25-
http://docs.python.org/library/simplehttpserver.html#module-SimpleHTTPServer
26-
"""
6+
"""Simple HTTP server for python-tuf tests"""
277

288
import socketserver
29-
import sys
309
from http.server import SimpleHTTPRequestHandler
31-
from typing import Type, Union
32-
33-
34-
class QuietHTTPRequestHandler(SimpleHTTPRequestHandler):
35-
"""A SimpleHTTPRequestHandler that does not write incoming requests to
36-
stderr."""
37-
38-
def log_request(
39-
self, code: Union[int, str] = "-", size: Union[int, str] = "-"
40-
) -> None:
41-
pass
42-
43-
44-
# NOTE: On Windows/Python2 tests that use this simple_server.py in a
45-
# subprocesses hang after a certain amount of requests (~68), if a PIPE is
46-
# passed as Popen's stderr argument. This problem doesn't emerge if
47-
# we silence the HTTP messages.
48-
# If you decide to receive the HTTP messages, then this bug
49-
# could reappear.
50-
51-
# pylint: disable=invalid-name
52-
handler: Type[Union[SimpleHTTPRequestHandler, QuietHTTPRequestHandler]]
53-
54-
if len(sys.argv) > 2 and sys.argv[2]:
55-
handler = QuietHTTPRequestHandler
56-
else:
57-
handler = SimpleHTTPRequestHandler
5810

5911
# Allow re-use so you can re-run tests as often as you want even if the
6012
# tests re-use ports. Otherwise TCP TIME-WAIT prevents reuse for ~1 minute
6113
socketserver.TCPServer.allow_reuse_address = True
6214

63-
httpd = socketserver.TCPServer(("localhost", 0), handler)
15+
httpd = socketserver.TCPServer(("localhost", 0), SimpleHTTPRequestHandler)
6416
port_message = "bind succeeded, server port is: " + str(httpd.server_address[1])
6517
print(port_message)
6618
httpd.serve_forever()

0 commit comments

Comments
 (0)