Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytest/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "testsolar-pytestx"
version = "0.1.73"
version = "0.1.75"
description = "Pytest tool for TestSolar"
authors = [
{name = "asiazhang2002", email = "asiazhang2002@gmail.com"},
Expand Down
19 changes: 17 additions & 2 deletions pytest/src/testsolar_pytestx/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,26 @@


def _get_desc(item: Item) -> str:
# 优先检查函数的docstring
try:
doc = item.function.__doc__ # type: ignore
if doc:
doc_str = str(doc).strip()
if doc_str and doc_str != "main entrance, discovered by pytest":
return doc_str
except AttributeError:
return ""
return str(doc).strip() if doc else ""
pass

# 检查类的docstring(HttpRunner测试用例)
try:
if hasattr(item, "cls") and item.cls and item.cls.__doc__:
class_doc = item.cls.__doc__.strip()
if class_doc:
return str(class_doc)
except (AttributeError, TypeError):
pass

return ""


def _iter_markers(item: Item) -> List[Mark]:
Expand Down
3 changes: 2 additions & 1 deletion pytest/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ def test_parse_case_attributes():
coding_testcase_id: 123,456
"""
item.own_markers = []
item.cls = None # 确保没有类级别的docstring

comment_fields = ["description", "owner", "coding_testcase_id"]
expected = {
"description": "This is a test function",
"description": "This is a test function", # 从注释中解析出的description字段值
"owner": "test_owner",
"coding_testcase_id": '["123", "456"]',
"tags": "[]",
Expand Down
2 changes: 1 addition & 1 deletion pytest/testtool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ schemaVersion: 1.0
name: pytest
nameZh: pytest自动化测试
lang: python
version: '0.1.73'
version: '0.1.75'
langType: INTERPRETED
description: |-
pytest是一个成熟的全功能Python测试工具,可以帮助您编写更好的程序。此测试工具允许您在TestSolar上运行pytest。
Expand Down