Skip to content

Commit f97d7e2

Browse files
authored
Merge pull request #163 from xverges/XV_flow_test_json_report
Fix the JSON report on dialog flow tests
2 parents c32b273 + 2c2671d commit f97d7e2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

dialog_test/flowtest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23
import sys
34
import flowtest_v1
@@ -112,9 +113,10 @@ def processFile(flowfile:str, watsonSDKVersion:str):
112113

113114
# Json is a list. So you save differently.
114115
filename = os.path.join(OUTPUT_FOLDER, '{}_report.json'.format(basefilename))
115-
with open(filename, 'w') as file_handler:
116-
for item in results:
117-
file_handler.write("{}\n".format(item))
116+
with open(filename, 'w', encoding='utf-8') as file_handler:
117+
compact = results.to_json(orient='records')
118+
readable = json.dumps(json.loads(compact), indent=2)
119+
file_handler.write(readable)
118120

119121

120122
#print('Report in by intent structure')

0 commit comments

Comments
 (0)