aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2021-06-11 15:09:25 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2021-06-11 15:10:32 +0200
commite2a7ac290649fe12228604876fdd63976734bec5 (patch)
tree1d70528837a0db7d392586b3506c7843d861a758 /xtesting
parent5389151567d189fb65fcded344929dcc319f2db3 (diff)
Fix tag logics in behave
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>
Diffstat (limited to 'xtesting')
-rw-r--r--xtesting/core/behaveframework.py6
-rw-r--r--xtesting/tests/unit/core/test_behaveframework.py12
2 files changed, 10 insertions, 8 deletions
diff --git a/xtesting/core/behaveframework.py b/xtesting/core/behaveframework.py
index e288fff8..ee6e8603 100644
--- a/xtesting/core/behaveframework.py
+++ b/xtesting/core/behaveframework.py
@@ -78,7 +78,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
@@ -88,12 +87,13 @@ 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)]
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:
diff --git a/xtesting/tests/unit/core/test_behaveframework.py b/xtesting/tests/unit/core/test_behaveframework.py
index 72fa6f29..7cfcdec7 100644
--- a/xtesting/tests/unit/core/test_behaveframework.py
+++ b/xtesting/tests/unit/core/test_behaveframework.py
@@ -84,7 +84,7 @@ class RunTesting(unittest.TestCase):
# pylint: disable=missing-docstring
suites = ["foo"]
- tags = []
+ tags = ["bar"]
def setUp(self):
self.test = behaveframework.BehaveFramework(
@@ -118,11 +118,12 @@ 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),
'--format=behave_html_formatter:HTMLFormatter',
- '--outfile={}'.format(html_file)]
+ '--outfile={}'.format(html_file),
+ '--tags='+','.join(self.tags)]
args_list.append('foo')
args[0].assert_called_once_with(args_list)
mock_method.assert_called_once_with()
@@ -150,11 +151,12 @@ 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),
'--format=behave_html_formatter:HTMLFormatter',
- '--outfile={}'.format(html_file)]
+ '--outfile={}'.format(html_file),
+ '--tags='+','.join(self.tags)]
if console:
args_list += ['--format=pretty', '--outfile=-']
args_list.append('foo')