mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
convert datetime object to string in summary data structure
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
__title__ = 'HttpRunner'
|
||||
__description__ = 'One-stop solution for HTTP(S) testing.'
|
||||
__url__ = 'https://github.com/HttpRunner/HttpRunner'
|
||||
__version__ = '1.5.2'
|
||||
__version__ = '1.5.3'
|
||||
__author__ = 'debugtalk'
|
||||
__author_email__ = 'mail@debugtalk.com'
|
||||
__license__ = 'MIT'
|
||||
|
||||
@@ -49,7 +49,7 @@ def get_summary(result):
|
||||
|
||||
if getattr(result, "records", None):
|
||||
summary["time"] = {
|
||||
'start_at': datetime.fromtimestamp(result.start_at),
|
||||
'start_at': result.start_at,
|
||||
'duration': result.duration
|
||||
}
|
||||
summary["records"] = result.records
|
||||
@@ -77,14 +77,15 @@ def render_html_report(summary, html_report_name=None, html_report_template=None
|
||||
logger.log_debug("render data: {}".format(summary))
|
||||
|
||||
report_dir_path = os.path.join(os.getcwd(), "reports")
|
||||
start_datetime = summary["time"]["start_at"].strftime('%Y-%m-%d-%H-%M-%S')
|
||||
start_at_timestamp = int(summary["time"]["start_at"])
|
||||
summary["time"]["start_datetime"] = datetime.fromtimestamp(start_at_timestamp).strftime('%Y-%m-%d %H:%M:%S')
|
||||
if html_report_name:
|
||||
summary["html_report_name"] = html_report_name
|
||||
report_dir_path = os.path.join(report_dir_path, html_report_name)
|
||||
html_report_name += "-{}.html".format(start_datetime)
|
||||
html_report_name += "-{}.html".format(start_at_timestamp)
|
||||
else:
|
||||
summary["html_report_name"] = ""
|
||||
html_report_name = "{}.html".format(start_datetime)
|
||||
html_report_name = "{}.html".format(start_at_timestamp)
|
||||
|
||||
if not os.path.isdir(report_dir_path):
|
||||
os.makedirs(report_dir_path)
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
<tr>
|
||||
<th>START AT</th>
|
||||
<td colspan="4">{{time.start_at.strftime('%Y-%m-%d %H:%M:%S')}}</td>
|
||||
<td colspan="4">{{time.start_datetime}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>DURATION</th>
|
||||
|
||||
Reference in New Issue
Block a user