Fix tag logics in behave 74/72674/3
authorCédric Ollivier <cedric.ollivier@orange.com>
Fri, 11 Jun 2021 13:09:25 +0000 (15:09 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Thu, 19 Aug 2021 13:15:25 +0000 (15:15 +0200)
The unit tests will be fully rewritten in a second change (out of this
bugfix).

Co-Authored-By: Ugur Caglar Kilic <ugur.caglar.kilic@oracle.com>
Change-Id: I6413fbcecdf44dbfe9c978045f4b1d43ca0de2ec
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit e2a7ac290649fe12228604876fdd63976734bec5)
(cherry picked from commit 261536179b363e0260e4e0068e4471bfb7c63b60)

xtesting/core/behaveframework.py
xtesting/tests/unit/core/test_behaveframework.py

index dacda27..2ee54d0 100644 (file)
@@ -80,7 +80,6 @@ class BehaveFramework(testcase.TestCase):
         """
         try:
             suites = kwargs["suites"]
-            tags = kwargs.get("tags", [])
         except KeyError:
             self.__logger.exception("Mandatory args were not passed")
             return self.EX_RUN_ERROR
@@ -90,13 +89,14 @@ class BehaveFramework(testcase.TestCase):
             except Exception:  # pylint: disable=broad-except
                 self.__logger.exception("Cannot create %s", self.res_dir)
                 return self.EX_RUN_ERROR
-        config = ['--tags='+','.join(tags),
-                  '--junit', '--junit-directory={}'.format(self.res_dir),
+        config = ['--junit', '--junit-directory={}'.format(self.res_dir),
                   '--format=json', '--outfile={}'.format(self.json_file)]
         if six.PY3:
             html_file = os.path.join(self.res_dir, 'output.html')
             config += ['--format=behave_html_formatter:HTMLFormatter',
                        '--outfile={}'.format(html_file)]
+        if kwargs.get("tags", False):
+            config += ['--tags='+','.join(kwargs.get("tags", []))]
         if kwargs.get("console", False):
             config += ['--format=pretty', '--outfile=-']
         for feature in suites:
index 2baaba0..00515ce 100644 (file)
@@ -85,7 +85,7 @@ class RunTesting(unittest.TestCase):
     # pylint: disable=missing-docstring
 
     suites = ["foo"]
-    tags = []
+    tags = ["bar"]
 
     def setUp(self):
         self.test = behaveframework.BehaveFramework(
@@ -119,13 +119,14 @@ class RunTesting(unittest.TestCase):
                 self.test.EX_OK)
             html_file = os.path.join(self.test.res_dir, 'output.html')
             args_list = [
-                '--tags=', '--junit',
+                '--junit',
                 '--junit-directory={}'.format(self.test.res_dir),
                 '--format=json', '--outfile={}'.format(self.test.json_file)]
             if six.PY3:
                 args_list += [
                     '--format=behave_html_formatter:HTMLFormatter',
                     '--outfile={}'.format(html_file)]
+            args_list.append('--tags='+','.join(self.tags))
             args_list.append('foo')
             args[0].assert_called_once_with(args_list)
             mock_method.assert_called_once_with()
@@ -153,13 +154,14 @@ class RunTesting(unittest.TestCase):
             status)
         html_file = os.path.join(self.test.res_dir, 'output.html')
         args_list = [
-            '--tags=', '--junit',
+            '--junit',
             '--junit-directory={}'.format(self.test.res_dir),
             '--format=json', '--outfile={}'.format(self.test.json_file)]
         if six.PY3:
             args_list += [
                 '--format=behave_html_formatter:HTMLFormatter',
                 '--outfile={}'.format(html_file)]
+        args_list.append('--tags='+','.join(self.tags))
         if console:
             args_list += ['--format=pretty', '--outfile=-']
         args_list.append('foo')