I designed a robot framework testing library, a specific method defined as below:
import json
from robot.api import logger
...
@staticmethod
def select_list_first_element_info(select_list, select_key):
if select_list and isinstance(select_list, list) and select_key:
data_dict = select_list[0]
json_dict = json.loads(data_dict)
if select_key in json_dict.keys():
return json_dict.get(select_key)
else:
logger.error(r"%s cannot be found in keys of dict variable json_dict." % select_key, html=True)
return ""
else:
logger.error(r"select_list is not valid list or select_key is null.", html=True)
return ""
But, I/O error occurred regardless of html=True or not.
20180302 01:18:55.723 - INFO - +--- START KW: lhvapi.Select List First Element Info [ ${dc_list} | ${key_dcid} ]
20180302 01:18:55.724 - ERROR - select_list is not valid list or select_key is null.
20180302 01:18:55.727 - FAIL - OSError: [Errno 5] Input/output error
20180302 01:18:55.727 - DEBUG - Traceback (most recent call last):
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/lhvapi/LhvRequests.py", line 162, in select_list_first_element_info
logger.error(r"select_list is not valid list or select_key is null.", html=True)
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/robot/api/logger.py", line 131, in error
write(msg, 'ERROR', html)
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/robot/api/logger.py", line 88, in write
librarylogger.write(msg, level, html)
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/robot/output/librarylogger.py", line 44, in write
LOGGER.log_message(Message(msg, level, html))
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/robot/output/logger.py", line 154, in _log_message
self.message(msg)
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/robot/output/logger.py", line 141, in message
logger.message(msg)
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/robot/output/console/quiet.py", line 28, in message
self._stderr.error(msg.message, msg.level)
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/robot/output/console/highlighting.py", line 74, in error
self.write(' ] %s\n' % message)
File "/home/autorunner/virtual_env/lib/python3.6/site-packages/robot/output/console/highlighting.py", line 51, in write
self.stream.write(console_encode(text, stream=self.stream))
OS: CentOS Linux release 7.4.1708 (Core)
Python: v3.6.3
Robot Framework: v3.0.2