Skip to content

Commit

Permalink
Simplify HTTP connection code (#116)
Browse files Browse the repository at this point in the history
We removed python 2.x support in #102, so this code should and can be simplified.

Test plan: `make -j test`
  • Loading branch information
Tony Tung authored Aug 30, 2019
1 parent 32a55c6 commit b2be1a1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 33 deletions.
11 changes: 3 additions & 8 deletions tests/io_/v0_0_0/test_caching_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@ def setUp(self, timeout_seconds=5):
self.contexts.append(self.tempdir)
self.port = unused_tcp_port()

if sys.version_info[0] == 2:
module = "SimpleHTTPServer"
elif sys.version_info[0] == 3:
module = "http.server"
else:
raise Exception("unknown python version")

self.contexts.append(ContextualChildProcess(
[
"python",
"-m",
module,
"http.server",
str(self.port),
"--bind",
"127.0.0.1",
],
cwd=self.tempdir.name,
).__enter__())
Expand Down
11 changes: 3 additions & 8 deletions tests/io_/v0_0_0/test_http_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@ def setUp(self, timeout_seconds=5):
self.contexts.append(self.tempdir)
self.port = unused_tcp_port()

if sys.version_info[0] == 2:
module = "SimpleHTTPServer"
elif sys.version_info[0] == 3:
module = "http.server"
else:
raise Exception("unknown python version")

self.contexts.append(ContextualChildProcess(
[
"python",
"-m",
module,
"http.server",
str(self.port),
"--bind",
"127.0.0.1",
],
cwd=self.tempdir.name,
).__enter__())
Expand Down
11 changes: 3 additions & 8 deletions tests/io_/v0_1_0/test_caching_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ def setUp(self, timeout_seconds=5):
self.contexts.append(self.tempdir)
self.port = unused_tcp_port()

if sys.version_info[0] == 2:
module = "SimpleHTTPServer"
elif sys.version_info[0] == 3:
module = "http.server"
else:
raise Exception("unknown python version")

self.contexts.append(ContextualChildProcess(
[
"python",
"-m",
module,
"http.server",
str(self.port),
"--bind",
"127.0.0.1",
],
cwd=self.tempdir.name,
).__enter__())
Expand Down
12 changes: 3 additions & 9 deletions tests/io_/v0_1_0/test_http_backend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import contextlib
import hashlib
import os
import sys
import tempfile
import threading
import time
Expand All @@ -24,19 +23,14 @@ def http_server(timeout_seconds=5):

port = unused_tcp_port()

if sys.version_info[0] == 2:
module = "SimpleHTTPServer"
elif sys.version_info[0] == 3:
module = "http.server"
else:
raise Exception("unknown python version")

with ContextualChildProcess(
[
"python",
"-m",
module,
"http.server",
str(port),
"--bind",
"127.0.0.1",
],
cwd=tempdir,
):
Expand Down

0 comments on commit b2be1a1

Please sign in to comment.