From 5093eefb73d0f01d383fe55fdf7fdbd63f8888f2 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Fri, 30 Jun 2017 05:04:20 +0200 Subject: Define ODL console_script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- functest/opnfv_tests/sdn/odl/odl.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) mode change 100755 => 100644 functest/opnfv_tests/sdn/odl/odl.py (limited to 'functest/opnfv_tests') diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py old mode 100755 new mode 100644 index fb5dcbc6..67bf66e3 --- 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 -- cgit 1.2.3-korg