Don't use directory argument with SimpleHTTPRequestHandler constructor
The `directory` argument has been added only since Python 3.7, which breaks the unit test on Python 3.6. Reimplement the intended behavior by overriding the `translate_path()` method, which takes the `directory` value into account on newer Python versions. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
eb427e2513
commit
3100882019
1 changed files with 7 additions and 1 deletions
|
|
@ -73,7 +73,13 @@ def can_setup_netns() -> bool:
|
|||
def runFileServer(barrier, directory):
|
||||
class Handler(http.server.SimpleHTTPRequestHandler):
|
||||
def __init__(self, request, client_address, server):
|
||||
super().__init__(request, client_address, server, directory=directory)
|
||||
super().__init__(request, client_address, server)
|
||||
|
||||
def translate_path(self, path: str) -> str:
|
||||
translated_path = super().translate_path(path)
|
||||
common = os.path.commonpath([translated_path, directory])
|
||||
translated_path = os.path.join(directory, os.path.relpath(translated_path, common))
|
||||
return translated_path
|
||||
|
||||
def guess_type(self, path):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue