提交 1af9ac3a 编写于 作者: L Lucas Meneghel Rodrigues 提交者: Lucas Meneghel Rodrigues

Merge pull request #58 from avocado-framework/new-tests

Add new avocado Functional Tests
......@@ -21,4 +21,7 @@ script:
- ./scripts/avocado run "bogustest" || test $? -ne 3
- export PYTHONPATH=$PYTHONPATH:.
- ./tests/sleeptest/sleeptest.py
- ./tests/skiptest/skiptest.py
- ./tests/failtest/failtest.py || test $? -eq 1
- ./tests/errortest/errortest.py || test $? -eq 1
- ./tests/warntest/warntest.py || test $? -eq 1
......@@ -21,8 +21,11 @@ class JobBaseException(Exception):
"""
The parent of all job exceptions.
You should be never raising this, but just in case, we'll set its
status' as FAIL.
"""
status = "NEVER_RAISE_THIS"
status = "FAIL"
class JobError(Exception):
......@@ -37,16 +40,19 @@ class TestBaseException(Exception):
"""
The parent of all test exceptions.
You should be never raising this, but just in case, we'll set its
status' as FAIL.
"""
status = "NEVER_RAISE_THIS"
status = "FAIL"
class TestSetupFail(TestBaseException):
"""
Indicates an error during a setup procedure.
Indicates an error during a setup or cleanup procedure.
"""
status = "FAIL"
status = "ERROR"
class TestError(TestBaseException):
......
......@@ -200,7 +200,10 @@ class Test(unittest.TestCase):
except Exception, details:
raise exceptions.TestSetupFail(details)
self.action()
self.cleanup()
try:
self.cleanup()
except Exception, details:
raise exceptions.TestSetupFail(details)
self.status = 'PASS'
def run_avocado(self, result=None):
......
#!/usr/bin/python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
from avocado import test
from avocado import job
from avocado.core import exceptions
class errortest(test.Test):
"""
Functional test for avocado. Throw a TestError.
"""
def action(self):
"""
This should throw a TestError.
"""
raise exceptions.TestError('This should throw a TestError')
if __name__ == "__main__":
job.main()
#!/usr/bin/python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
from avocado import test
from avocado import job
from avocado.core import exceptions
class skiptest(test.Test):
"""
Functional test for avocado. Throw a TestNAError (skips the test).
"""
def action(self):
"""
This should throw a TestNAError (skips the test).
"""
raise exceptions.TestNAError('This test should be skipped')
if __name__ == "__main__":
job.main()
#!/usr/bin/python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
from avocado import test
from avocado import job
from avocado.core import exceptions
class warntest(test.Test):
"""
Functional test for avocado. Throw a TestWarn.
"""
def action(self):
"""
This should throw a TestWarn.
"""
raise exceptions.TestWarn('This should throw a TestWarn')
if __name__ == "__main__":
job.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册