Skip to content

Commit 63d3027

Browse files
committed
Cleanups in tests and in framework
* Some Py2/Py3 compat blocks were simplified to Py3 only * some sequences of define-cleaup-function + atexit.register were changed to use the decorator (this works if func needs to take no arguments) * Lightly update a bunch of docstrings in TestCmd, and reformat a few places, towards the style we're generally using now. * call_python() in TestCmdTests was modernized to use subprocess.run Signed-off-by: Mats Wichmann <[email protected]>
1 parent 07ba471 commit 63d3027

File tree

7 files changed

+230
-287
lines changed

7 files changed

+230
-287
lines changed

test/SConscript/SConscript.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
test.write('SConstruct', """\
3535
import os
3636
import foo
37+
from collections import UserList
3738
3839
assert foo.foo == 4
3940
@@ -71,10 +72,6 @@
7172
7273
SConscript('SConscript5')
7374
74-
try:
75-
from collections import UserList
76-
except ImportError:
77-
from UserList import UserList
7875
x7 = "SConstruct x7"
7976
x8 = "SConstruct x8"
8077
x9 = SConscript('SConscript6', UserList(["x7", "x8"]))

test/option/option_profile.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,9 @@
2424

2525
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
2626

27-
import sys
28-
29-
# TODO: Fixup StringIO usage when Py2.7 is dropped.
30-
# cheat a little bit: io.StringIO is "preferred" in Py2.7
31-
# since it forces you to be explicit about strings (it is unicode-only)
32-
# It's easier to use the unaware version. Which also doesn't come
33-
# with a context manager, so use contextlib.closing
34-
try:
35-
from cStringIO import StringIO
36-
except ImportError:
37-
from io import StringIO
3827
import contextlib
28+
import sys
29+
from io import StringIO
3930

4031
import TestSCons
4132

test/redirection.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
test.write('cat.py', r"""
3434
import sys
35-
PY3K = sys.version_info >= (3, 0)
3635
3736
# write binary to stdout
3837
if sys.platform == "win32":
@@ -45,17 +44,10 @@
4544
with open(sys.argv[1], 'rb') as f:
4645
indata = f.read()
4746
except IndexError:
48-
if PY3K:
49-
source = sys.stdin.buffer
50-
else:
51-
source = sys.stdin
47+
source = sys.stdin
5248
indata = source.read()
5349
54-
if PY3K:
55-
sys.stdout.buffer.write(indata)
56-
else:
57-
sys.stdout.write(indata)
58-
50+
sys.stdout.buffer.write(indata)
5951
sys.exit(0)
6052
""")
6153

0 commit comments

Comments
 (0)