61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
|
from os import system as exec_system_command
|
||
|
from os.path import exists as is_file_exists
|
||
|
from os.path import dirname
|
||
|
from sys import argv as term_args
|
||
|
from sys import executable
|
||
|
import platform
|
||
|
|
||
|
|
||
|
if __name__ != '__main__':
|
||
|
raise SystemExit('The current file can only be run as the main program, and it is forbidden to be imported.')
|
||
|
|
||
|
first_command_status = exec_system_command("""
|
||
|
pytest --alluredir ./allure-results --clean-alluredir %s
|
||
|
""" % "\x20".join(term_args[1:]))
|
||
|
|
||
|
allure_results = '%s/allure-results' % dirname(__file__)
|
||
|
allure_results_categories = '%s/categories.json' % allure_results
|
||
|
allure_results_categories_content = """
|
||
|
[
|
||
|
{
|
||
|
"name": "通过",
|
||
|
"matchedStatuses": [
|
||
|
"passed"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "失败",
|
||
|
"matchedStatuses": [
|
||
|
"failed"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "测试发生错误",
|
||
|
"matchedStatuses": [
|
||
|
"broken"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "加载超时异常",
|
||
|
"matchedStatuses": [
|
||
|
"broken"
|
||
|
],
|
||
|
"messageRegex": ".*TimeoutException.*"
|
||
|
}
|
||
|
]
|
||
|
"""
|
||
|
allure_results_environment_properties = '%s/environment.properties' % allure_results
|
||
|
allure_results_environment_properties_content = """
|
||
|
OS = %s
|
||
|
Python = %s
|
||
|
Execute = %s
|
||
|
""" % (
|
||
|
('%s (%s %s) %s' % (platform.node(), platform.system(), platform.release(), platform.machine().lower())),
|
||
|
('%s' % (platform.python_version())),
|
||
|
executable.replace("\\", '/')
|
||
|
)
|
||
|
is_file_exists(allure_results) and open(allure_results_categories, mode='w', encoding='utf-8').write(allure_results_categories_content)
|
||
|
is_file_exists(allure_results) and open(allure_results_environment_properties, mode='w', encoding='utf-8').write(allure_results_environment_properties_content)
|
||
|
|
||
|
exit(first_command_status)
|