Skip to content

Commit 1f8863b

Browse files
Kostiantyn GoloveshkoKostiantyn Goloveshko
authored andcommitted
Fix failing integration between Allure and pytest_bdd when test parameter is dict
1 parent 3c74fd5 commit 1f8863b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

allure-python-commons/src/logger.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
import json
66
import uuid
77
import shutil
8+
89
from six import text_type
910
from attr import asdict
1011
from allure_commons import hookimpl
1112

13+
from allure_commons.model2 import TestResult
14+
1215
INDENT = 4
1316

1417

@@ -32,6 +35,12 @@ def _report_item(self, item):
3235
indent = INDENT if os.environ.get("ALLURE_INDENT_OUTPUT") else None
3336
filename = item.file_pattern.format(prefix=uuid.uuid4())
3437
data = asdict(item, filter=lambda attr, value: not (type(value) != bool and not bool(value)))
38+
39+
if isinstance(item, TestResult) and 'parameters' in data.keys():
40+
for parameter in data['parameters']:
41+
if isinstance(parameter['value'], dict):
42+
parameter['value'] = json.dumps(parameter['value'])
43+
3544
with io.open(os.path.join(self._report_dir, filename), 'w', encoding='utf8') as json_file:
3645
if sys.version_info.major < 3:
3746
json_file.write(

0 commit comments

Comments
 (0)