2016-12-24 22:46:22 +01:00
|
|
|
import os
|
2017-04-10 13:13:22 +02:00
|
|
|
from datetime import datetime
|
2016-12-24 22:46:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
def save_logs(groomer, test_description):
|
|
|
|
divider = ('=' * 10 + '{}' + '=' * 10 + '\n')
|
|
|
|
test_log_path = 'tests/test_logs/{}.log'.format(test_description)
|
|
|
|
with open(test_log_path, 'w+') as test_log:
|
|
|
|
test_log.write(divider.format('TEST LOG'))
|
2017-04-10 13:13:22 +02:00
|
|
|
test_log.write(str(datetime.now().time()) + '\n')
|
|
|
|
test_log.write(test_description + '\n')
|
|
|
|
test_log.write('-' * 20 + '\n')
|
2017-03-18 05:10:17 +01:00
|
|
|
with open(groomer.logger.log_path, 'r') as logfile:
|
2016-12-24 22:46:22 +01:00
|
|
|
log = logfile.read()
|
|
|
|
test_log.write(log)
|
2017-03-18 03:19:56 +01:00
|
|
|
if os.path.exists(groomer.logger.log_debug_err):
|
|
|
|
test_log.write(divider.format('ERR LOG'))
|
|
|
|
with open(groomer.logger.log_debug_err, 'r') as debug_err:
|
|
|
|
err = debug_err.read()
|
|
|
|
test_log.write(err)
|
|
|
|
if os.path.exists(groomer.logger.log_debug_out):
|
|
|
|
test_log.write(divider.format('OUT LOG'))
|
|
|
|
with open(groomer.logger.log_debug_out, 'r') as debug_out:
|
|
|
|
out = debug_out.read()
|
|
|
|
test_log.write(out)
|