Skip to content

Commit d770f54

Browse files
authored
Merge pull request #92 from OpenTestSolar/dev/ignore-exit-code-5
忽略pytest执行退出码为5的情况
2 parents 81fee61 + e632118 commit d770f54

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

‎pytest/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "testsolar-pytestx"
3-
version = "0.1.36"
3+
version = "0.1.37"
44
description = "Pytest tool for TestSolar"
55
authors = [
66
{name = "asiazhang2002", email = "asiazhang2002@gmail.com"},

‎pytest/src/testsolar_pytestx/executor.py‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,22 @@ def run_testcases(
264264
my_plugin = PytestExecutor(reporter=reporter, comment_fields=case_comment_fields)
265265
_, captured_stderr, exit_code = pytest_main_with_output(args=args, plugin=my_plugin)
266266
if exit_code != 0:
267-
# 若pytest没有成功执行,则将本批次的用例结果统一设置为FAILED,并将标准错误流作为用例错误日志上报
268-
msg = f"Pytest run exit with code {exit_code}"
269-
logger.error(msg)
270-
if my_plugin.testcase_count == 0:
271-
for selector in valid_selectors:
272-
test_result = TestResult(
273-
Test=TestCase(Name=selector),
274-
ResultType=ResultType.FAILED,
275-
StartTime=datetime.utcnow(),
276-
Message=captured_stderr or msg,
277-
)
278-
reporter.report_case_result(test_result)
279-
return
267+
if exit_code == 5:
268+
logger.warning("all testcases has been filtered")
269+
else:
270+
# 若pytest没有成功执行,则将本批次的用例结果统一设置为FAILED,并将标准错误流作为用例错误日志上报
271+
msg = f"Pytest run exit with code {exit_code}"
272+
logger.error(msg)
273+
if my_plugin.testcase_count == 0:
274+
for selector in valid_selectors:
275+
test_result = TestResult(
276+
Test=TestCase(Name=selector),
277+
ResultType=ResultType.FAILED,
278+
StartTime=datetime.utcnow(),
279+
Message=captured_stderr or msg,
280+
)
281+
reporter.report_case_result(test_result)
282+
return
280283
if len(code_packages) > 0:
281284
# 如果存在需要采集覆盖率的代码包,则生成覆盖率报告
282285
collect_coverage_report(entry.ProjectPath, entry.FileReportPath, code_packages)

‎pytest/testtool.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ schemaVersion: 1.0
22
name: pytest
33
nameZh: pytest自动化测试
44
lang: python
5-
version: '0.1.36'
5+
version: '0.1.37'
66
langType: INTERPRETED
77
description: |-
88
pytest是一个成熟的全功能Python测试工具,可以帮助您编写更好的程序。此测试工具允许您在TestSolar上运行pytest。

0 commit comments

Comments
 (0)