diff --git a/avocado/core/sysinfo.py b/avocado/core/sysinfo.py index 1838d541d9a50f5a762bb68142a38d5dd14366b5..5179015f34085153aff34969f18778fae251cefb 100644 --- a/avocado/core/sysinfo.py +++ b/avocado/core/sysinfo.py @@ -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) diff --git a/selftests/functional/test_output.py b/selftests/functional/test_output.py index f6d47a95e372a1afe11bb962f830710ded8b03c9..7a19f2620b076580ece5edda3e46103f207b4c75 100644 --- a/selftests/functional/test_output.py +++ b/selftests/functional/test_output.py @@ -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") diff --git a/selftests/functional/test_standalone.py b/selftests/functional/test_standalone.py index 8ab24c4979f9b3df1f4ef19d745e3a7848b0bd13..b6734a48b0492a024ef49f26b677903e9d983d13 100644 --- a/selftests/functional/test_standalone.py +++ b/selftests/functional/test_standalone.py @@ -1,4 +1,5 @@ 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: