diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-06-30 05:04:20 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-06-30 05:12:39 +0200 |
commit | 5093eefb73d0f01d383fe55fdf7fdbd63f8888f2 (patch) | |
tree | 42599a4431a16809bb32e7fde98796366224ed21 /functest/opnfv_tests | |
parent | fbc676b2bcf63382a39c5b54d47c608a20a8cfea (diff) |
Define ODL console_script
main() is excluded from coverage as it usually parses argv.
It also renames ODLTests main() to run_suites() not to exclude this
method.
Change-Id: I3109a65166b21d93e3e376912a32d364931a7ba5
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/opnfv_tests')
-rw-r--r--[-rwxr-xr-x] | functest/opnfv_tests/sdn/odl/odl.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index fb5dcbc6..67bf66e3 100755..100644 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -117,7 +117,7 @@ class ODLTests(testcase.TestCase): self.details['description'] = result.suite.name self.details['tests'] = visitor.get_data() - def main(self, suites=None, **kwargs): + def run_suites(self, suites=None, **kwargs): """Run the test suites It has been designed to be called in any context. @@ -246,7 +246,7 @@ class ODLTests(testcase.TestCase): self.__logger.exception("Cannot run ODL testcases.") return self.EX_RUN_ERROR - return self.main(suites, **kwargs) + return self.run_suites(suites, **kwargs) class ODLParser(object): # pylint: disable=too-few-public-methods @@ -301,16 +301,19 @@ class ODLParser(object): # pylint: disable=too-few-public-methods return vars(self.parser.parse_args(argv)) -if __name__ == '__main__': +def main(): + """Entry point""" logging.basicConfig() - ODL = ODLTests() - PARSER = ODLParser() - ARGS = PARSER.parse_args(sys.argv[1:]) + odl = ODLTests() + parser = ODLParser() + args = parser.parse_args(sys.argv[1:]) try: - RESULT = ODL.main(ODLTests.default_suites, **ARGS) - if RESULT != testcase.TestCase.EX_OK: - sys.exit(RESULT) - if ARGS['pushtodb']: - sys.exit(ODL.push_to_db()) + result = odl.run_suites(ODLTests.default_suites, **args) + if result != testcase.TestCase.EX_OK: + return result + if args['pushtodb']: + return odl.push_to_db() + else: + return result except Exception: # pylint: disable=broad-except - sys.exit(testcase.TestCase.EX_RUN_ERROR) + return testcase.TestCase.EX_RUN_ERROR |