未验证 提交 3f9bb7c6 编写于 作者: A Amador Pahim

Merge branch 'clebergnu-selftests_and_misc_fixes_3rd_batch'

Signed-off-by: NAmador Pahim <apahim@redhat.com>
......@@ -170,10 +170,10 @@ class Command(Collectible):
env=env)
logf_path = os.path.join(logdir, self.logf)
if self._compress_log:
with gzip.GzipFile(logf_path, 'w') as logf:
with gzip.GzipFile(logf_path, 'wb') as logf:
logf.write(result.stdout)
else:
with open(logf_path, 'w') as logf:
with open(logf_path, 'wb') as logf:
logf.write(result.stdout)
......
......@@ -41,7 +41,7 @@ import sys
from avocado import Test
from avocado.utils import process
print "top_print"
print("top_print")
sys.stdout.write("top_stdout\\n")
sys.stderr.write("top_stderr\\n")
process.run("/bin/echo top_process")
......@@ -49,13 +49,13 @@ process.run("/bin/echo top_process")
class OutputTest(Test):
def __init__(self, *args, **kwargs):
super(OutputTest, self).__init__(*args, **kwargs)
print "init_print"
print("init_print")
sys.stdout.write("init_stdout\\n")
sys.stderr.write("init_stderr\\n")
process.run("/bin/echo init_process")
def test(self):
print "test_print"
print("test_print")
sys.stdout.write("test_stdout\\n")
sys.stderr.write("test_stderr\\n")
process.run("/bin/echo -n test_process > /dev/stdout",
......@@ -66,7 +66,7 @@ class OutputTest(Test):
shell=True)
def __del__(self):
print "del_print"
print("del_print")
sys.stdout.write("del_stdout\\n")
sys.stderr.write("del_stderr\\n")
process.run("/bin/echo -n del_process")
......
import os
import sys
import unittest
from avocado.core import exit_codes
......@@ -45,7 +46,10 @@ class StandaloneTests(unittest.TestCase):
cmd_line = './examples/tests/errortest_nasty.py -r'
expected_rc = exit_codes.AVOCADO_TESTS_FAIL
result = self.run_and_check(cmd_line, expected_rc, 'errortest_nasty')
exc = "NastyException: Nasty-string-like-exception"
if sys.version_info[0] == 3:
exc = "errortest_nasty.NastyException: Nasty-string-like-exception"
else:
exc = "NastyException: Nasty-string-like-exception"
count = result.stdout.count("\n%s" % exc)
self.assertEqual(count, 2, "Exception \\n%s should be present twice in"
"the log (once from the log, second time when parsing"
......@@ -62,8 +66,11 @@ class StandaloneTests(unittest.TestCase):
cmd_line = './examples/tests/errortest_nasty3.py -r'
expected_rc = exit_codes.AVOCADO_TESTS_FAIL
result = self.run_and_check(cmd_line, expected_rc, 'errortest_nasty3')
self.assertIn("TestError: <errortest_nasty3.NastyException instance at ",
result.stdout)
if sys.version_info[0] == 3:
exc = "TypeError: exceptions must derive from BaseException"
else:
exc = "TestError: <errortest_nasty3.NastyException instance at "
self.assertIn(exc, result.stdout)
def test_errortest(self):
cmd_line = './examples/tests/errortest.py -r'
......
......@@ -144,7 +144,7 @@ class ProcessTest(unittest.TestCase):
time.sleep(3)
proc.terminate()
proc.wait()
stdout = proc.get_stdout()
stdout = proc.get_stdout().decode()
self.assertIn('memory', stdout, 'result: %s' % stdout)
self.assertRegexpMatches(stdout, '[0-9]+')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册