avocado.test: Complement compatibility with unittest.TestCase()
Make avocado.test.Test() to be compatible with unittest.TestCase(),
by making it take the methodName param, that will be largely for
the sake of compatibility. With this, we can run avocado tests
with unittest.main() and nosetests just fine:
$ nosetests tests/sleeptest/sleeptest.py
.
----------------------------------------------------------------------
Ran 1 test in 1.096s
OK
$ nosetests tests/failtest/failtest.py
E
======================================================================
ERROR: Run test method, for compatibility with unittest.TestCase.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/lmr/Code/avocado/avocado/test.py", line 180, in runTest
self.action()
File "/home/lmr/Code/avocado/tests/failtest/failtest.py", line 33, in
action
raise exceptions.TestFail('This test is supposed to fail')
TestFail: This test is supposed to fail
----------------------------------------------------------------------
Ran 1 test in 0.088s
FAILED (errors=1)
In order to do this, the code in runTest was split to
an unhandled method, to be used by nosetests and the
unittest runner, and another one, to be used inside
avocado (run_avocado).
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
Showing
想要评论请 注册 或 登录