summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2020-02-18 19:33:37 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2020-02-18 19:33:37 (GMT)
commit73a6eb497276e8ed8b8c81204d8b25a728ac84e9 (patch)
tree66107e004fdf5be5c8168dea13f23467a3a6f640 /testing
parente66f178d42d9d6f323be8884c8d1e80e3936d0a3 (diff)
downloadSCons-73a6eb497276e8ed8b8c81204d8b25a728ac84e9.zip
SCons-73a6eb497276e8ed8b8c81204d8b25a728ac84e9.tar.gz
SCons-73a6eb497276e8ed8b8c81204d8b25a728ac84e9.tar.bz2
Update TestCommonTests.py to work with py35+ changes
Diffstat (limited to 'testing')
-rw-r--r--testing/framework/TestCommonTests.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py
index c54f33f..6377737 100644
--- a/testing/framework/TestCommonTests.py
+++ b/testing/framework/TestCommonTests.py
@@ -45,10 +45,9 @@ def lstrip(s):
lines = [ l[spaces:] for l in lines ]
return '\n'.join(lines)
-if sys.version[:3] == '1.5':
- expected_newline = '\\012'
-else:
- expected_newline = '\\n'
+
+expected_newline = '\\n'
+
def assert_display(expect, result, error=None):
try:
@@ -57,9 +56,9 @@ def assert_display(expect, result, error=None):
pass
result = [
'\n',
- ('*'*80) + '\n',
+ 'EXPECTED'+('*'*80) + '\n',
expect,
- ('*'*80) + '\n',
+ 'GOT'+('*'*80) + '\n',
result,
('*'*80) + '\n',
]
@@ -353,14 +352,13 @@ class must_contain_TestCase(TestCommonTestCase):
expect = lstrip("""\
File `file1' does not contain required string.
Required string ================================================================
- 1 c
+ b'1 c'
file1 contents =================================================================
- file1 does not match
-
+ b'file1 does not match\\n'
""")
run_env.run(program=sys.executable, stdin=script)
stdout = run_env.stdout()
- assert stdout == expect, repr(stdout)
+ assert stdout == expect, "got:\n%s\nexpected:\n%s"%(stdout, expect)
stderr = run_env.stderr()
assert stderr.find("FAILED") != -1, stderr
@@ -1294,7 +1292,7 @@ class must_not_contain_TestCase(TestCommonTestCase):
from TestCommon import TestCommon
tc = TestCommon(workdir='')
tc.write('file1', "file1 contents\\n")
- tc.must_not_contain('file1', "1 does not contain c")
+ tc.must_not_contain('file1', b"1 does not contain c")
tc.pass_test()
""")
run_env.run(program=sys.executable, stdin=script)
@@ -1327,20 +1325,20 @@ class must_not_contain_TestCase(TestCommonTestCase):
from TestCommon import TestCommon
tc = TestCommon(workdir='')
tc.write('file1', "file1 does contain contents\\n")
- tc.must_not_contain('file1', "1 does contain c")
+ tc.must_not_contain('file1', b"1 does contain c")
tc.run()
""")
expect = lstrip("""\
File `file1' contains banned string.
Banned string ==================================================================
- 1 does contain c
+ b'1 does contain c'
file1 contents =================================================================
- file1 does contain contents
-
+ b'file1 does contain contents\\n'
""")
run_env.run(program=sys.executable, stdin=script)
stdout = run_env.stdout()
- assert stdout == expect, repr(stdout)
+ assert stdout == expect, "\ngot:\n%s\nexpected:\n%s" % (stdout, expect)
+
stderr = run_env.stderr()
assert stderr.find("FAILED") != -1, stderr
@@ -1352,20 +1350,20 @@ class must_not_contain_TestCase(TestCommonTestCase):
from TestCommon import TestCommon
tc = TestCommon(workdir='')
tc.write('file1', "file1 does contain contents\\n")
- tc.must_not_contain('file1', "file1 does")
+ tc.must_not_contain('file1', b"file1 does")
tc.run()
""")
expect = lstrip("""\
File `file1' contains banned string.
Banned string ==================================================================
- file1 does
+ b'file1 does'
file1 contents =================================================================
- file1 does contain contents
-
+ b'file1 does contain contents\\n'
""")
run_env.run(program=sys.executable, stdin=script)
stdout = run_env.stdout()
- assert stdout == expect, repr(stdout)
+ assert stdout == expect, "\ngot:\n%s\nexpected:\n%s" % (stdout, expect)
+
stderr = run_env.stderr()
assert stderr.find("FAILED") != -1, stderr
@@ -1379,7 +1377,7 @@ class must_not_contain_TestCase(TestCommonTestCase):
tc.write('file1', "file1 contents\\n", mode='w')
tc.must_not_contain('file1', "1 does not contain c", mode='r')
tc.write('file2', "file2 contents\\n", mode='wb')
- tc.must_not_contain('file2', "2 does not contain c", mode='rb')
+ tc.must_not_contain('file2', b"2 does not contain c", mode='rb')
tc.pass_test()
""")
run_env.run(program=sys.executable, stdin=script)
@@ -1891,6 +1889,7 @@ class run_TestCase(TestCommonTestCase):
expect_stdout = lstrip("""\
STDOUT =========================================================================
+ None
STDERR =========================================================================
""")
@@ -1904,6 +1903,9 @@ class run_TestCase(TestCommonTestCase):
.*
File "[^"]+TestCommon.py", line \\d+, in start
raise e
+ File "[^"]+TestCommon.py", line \\d+, in start
+ return TestCmd.start\\(self, program, interpreter, arguments,
+ File "<stdin>", line \\d+, in raise_exception
TypeError: forced TypeError
""" % re.escape(repr(sys.executable)))
expect_stderr = re.compile(expect_stderr, re.M)
@@ -2172,7 +2174,7 @@ class run_TestCase(TestCommonTestCase):
tc.run()
""")
- self.SIGTERM = signal.SIGTERM
+ self.SIGTERM = int(signal.SIGTERM)
# Script returns the signal value as a negative number.
expect_stdout = lstrip("""\