Skip to content

Commit 113976c

Browse files
committed
testing: remove some unused code
1 parent e459c01 commit 113976c

File tree

6 files changed

+11
-47
lines changed

6 files changed

+11
-47
lines changed

execnet/gateway.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,15 @@ def rinfo_source(channel):
169169

170170
def _find_non_builtin_globals(source, codeobj):
171171
import ast
172-
173-
try:
174-
import __builtin__
175-
except ImportError:
176-
import builtins as __builtin__
172+
import builtins
177173

178174
vars = dict.fromkeys(codeobj.co_varnames)
179175
return [
180176
node.id
181177
for node in ast.walk(ast.parse(source))
182178
if isinstance(node, ast.Name)
183179
and node.id not in vars
184-
and node.id not in __builtin__.__dict__
180+
and node.id not in builtins.__dict__
185181
]
186182

187183

testing/test_basics.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def test_subprocess_interaction(anypython):
7575

7676
def send(line):
7777
popen.stdin.write(line)
78-
if sys.version_info > (3, 0) or sys.platform.startswith("java"):
79-
popen.stdin.flush()
78+
popen.stdin.flush()
8079

8180
def receive():
8281
return popen.stdout.readline()
@@ -121,10 +120,7 @@ def test_io_message(anypython, tmpdir, execmodel):
121120
py.code.Source(
122121
gateway_base,
123122
"""
124-
try:
125-
from io import BytesIO
126-
except ImportError:
127-
from StringIO import StringIO as BytesIO
123+
from io import BytesIO
128124
import tempfile
129125
temp_out = BytesIO()
130126
temp_in = BytesIO()

testing/test_channel.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import time
55

66
import pytest
7-
from test_gateway import _find_version
87

98

109
needs_early_gc = pytest.mark.skipif("not hasattr(sys, 'getrefcount')")
@@ -211,17 +210,14 @@ def check_channel_callback_stays_active(self, gw, earlyfree=True):
211210
l = []
212211
channel = gw.remote_exec(
213212
source="""
214-
try:
215-
import thread
216-
except ImportError:
217-
import _thread as thread
213+
import _thread
218214
import time
219215
def producer(subchannel):
220216
for i in range(5):
221217
time.sleep(0.15)
222218
subchannel.send(i*100)
223219
channel2 = channel.receive()
224-
thread.start_new_thread(producer, (channel2,))
220+
_thread.start_new_thread(producer, (channel2,))
225221
del channel2
226222
"""
227223
)

testing/test_gateway.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
mostly functional tests of gateways.
33
"""
44
import os
5-
import socket
6-
import subprocess
75
import sys
86
from textwrap import dedent
97

@@ -12,7 +10,6 @@
1210
import pytest
1311
from execnet import gateway_base
1412
from execnet import gateway_io
15-
from test_serializer import _find_version
1613

1714
TESTTIMEOUT = 10.0 # seconds
1815
needs_osdup = pytest.mark.skipif("not hasattr(os, 'dup')")

testing/test_rsync.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import py
33
import pytest
44
from execnet import RSync
5-
from test_serializer import _find_version
65

76

87
@pytest.fixture(scope="module")

testing/test_serializer.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import subprocess
32
import sys
43
import tempfile
@@ -10,26 +9,8 @@
109
MINOR_VERSIONS = {"3": "543210", "2": "76"}
1110

1211

13-
def _find_version(suffix=""):
14-
name = "python" + suffix
15-
executable = py.path.local.sysfind(name)
16-
if executable is None:
17-
if sys.platform == "win32" and suffix == "3":
18-
for name in ("python31", "python30"):
19-
executable = py.path.local(rf"c:\\{name}\python.exe")
20-
if executable.check():
21-
return executable
22-
for tail in MINOR_VERSIONS.get(suffix, ""):
23-
path = py.path.local.sysfind(f"{name}.{tail}")
24-
if path:
25-
return path
26-
27-
else:
28-
pytest.skip(f"can't find a {name!r} executable")
29-
return executable
30-
31-
32-
TEMPDIR = _py2_wrapper = _py3_wrapper = None
12+
TEMPDIR = None
13+
_py3_wrapper = None
3314

3415

3516
def setup_module(mod):
@@ -56,8 +37,8 @@ def dump(self, obj_rep):
5637
import sys
5738
sys.path.insert(0, %r)
5839
import gateway_base as serializer
59-
if sys.version_info > (3, 0): # Need binary output
60-
sys.stdout = sys.stdout.detach()
40+
# Need binary output
41+
sys.stdout = sys.stdout.detach()
6142
sys.stdout.write(serializer.dumps_internal(%s))
6243
"""
6344
% (pyimportdir, obj_rep)
@@ -83,8 +64,7 @@ def load(self, data, option_args="__class__"):
8364
import sys
8465
sys.path.insert(0, %r)
8566
import gateway_base as serializer
86-
if sys.version_info > (3, 0):
87-
sys.stdin = sys.stdin.detach()
67+
sys.stdin = sys.stdin.detach()
8868
loader = serializer.Unserializer(sys.stdin)
8969
loader.%s
9070
obj = loader.load()

0 commit comments

Comments
 (0)