提交 12a49c59 编写于 作者: C Cleber Rosa

selftests/functional/test_standalone.py: adapt to Python 3 exceptions

Which includes the module name, and the different treatment of
exceptions that do not inherit from BaseExcpetion.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 0b1c2dd2
import os
import sys
import unittest
from avocado.core import exit_codes
......@@ -45,6 +46,9 @@ 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')
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"
......@@ -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'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册