зеркало из https://github.com/mozilla/iris.git
Use shutils.get_terminal_size() instead of os.get_terminal_size()
When iris is running via taskcluster, os.get_terminal_size() throws an oserror. shutils.get_terminal_size() is a higher-level wrapper to os.get_terminal_size(), which falls back to some sane defaults when it fails to find the terminal size, so using it avoids the oserror.
This commit is contained in:
Родитель
fc10edb2f0
Коммит
d2b2e0522e
|
@ -6,6 +6,7 @@ from argparse import Namespace
|
|||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
@ -65,7 +66,7 @@ class BaseTarget:
|
|||
:param _pytest.main.Session session: the pytest session object.
|
||||
"""
|
||||
self.start_time = time.time()
|
||||
logger.info('\n' + 'Test session {} started'.format(session.name).center(os.get_terminal_size().columns, '-'))
|
||||
logger.info('\n' + 'Test session {} started'.format(session.name).center(shutil.get_terminal_size().columns, '-'))
|
||||
|
||||
core_settings_list = []
|
||||
for arg in vars(core_args):
|
||||
|
@ -93,7 +94,7 @@ class BaseTarget:
|
|||
result = footer.print_report_footer()
|
||||
create_run_log(self)
|
||||
|
||||
logger.info('\n' + 'Test session {} complete'.format(session.name).center(os.get_terminal_size().columns, '-'))
|
||||
logger.info('\n' + 'Test session {} complete'.format(session.name).center(shutil.get_terminal_size().columns, '-'))
|
||||
|
||||
if core_args.email:
|
||||
try:
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from src.core.api.os_helpers import OSHelper
|
||||
from src.core.util.path_manager import PathManager
|
||||
|
@ -28,8 +29,8 @@ class ReportFooter:
|
|||
def print_report_footer(self):
|
||||
"""Print report footer in a nice format."""
|
||||
total = self.passed_tests + self.failed_tests + self.skipped_tests + self.error_tests
|
||||
header = '\n' + 'Test Report'.center(os.get_terminal_size().columns, '-') + '\n'
|
||||
separator = '\n' + ''.center(os.get_terminal_size().columns, '-') + '\n'
|
||||
header = '\n' + 'Test Report'.center(shutil.get_terminal_size().columns, '-') + '\n'
|
||||
separator = '\n' + ''.center(shutil.get_terminal_size().columns, '-') + '\n'
|
||||
failure_str = ''
|
||||
|
||||
if len(self.failures) > 0:
|
||||
|
@ -43,14 +44,14 @@ class ReportFooter:
|
|||
app_details = 'Application: %s, Platform: %s%s' % (self.app.target_name, self.platform, additional_info)
|
||||
test_results_str = 'Passed: %s, Failed: %s, Skipped: %s, Errors %s -- Total: %s' \
|
||||
% (self.passed_tests, self.failed_tests, self.skipped_tests, self.error_tests, total)
|
||||
|
||||
|
||||
total_time_hours = int(self.total_duration / 3600)
|
||||
total_time_minutes = int((self.total_duration - (total_time_hours * 3600)) / 60)
|
||||
total_time_seconds = self.total_duration - (total_time_hours * 3600) - (total_time_minutes * 60)
|
||||
total_time_str = 'Total time: %02d:%02d:%06.3f' % (total_time_hours, total_time_minutes, total_time_seconds)
|
||||
|
||||
test_results = (header + app_details + '\n' + test_results_str + ' ' *
|
||||
(os.get_terminal_size().columns - (len(test_results_str) + len(total_time_str))) +
|
||||
(shutil.get_terminal_size().columns - (len(test_results_str) + len(total_time_str))) +
|
||||
total_time_str + failure_str + separator)
|
||||
|
||||
logger.info(test_results)
|
||||
|
|
Загрузка…
Ссылка в новой задаче