File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[project ]
22name = " testsolar-pytestx"
3- version = " 0.1.73 "
3+ version = " 0.1.75 "
44description = " Pytest tool for TestSolar"
55authors = [
66 {name = " asiazhang2002" , email = " asiazhang2002@gmail.com" },
Original file line number Diff line number Diff line change 2222
2323
2424def _get_desc (item : Item ) -> str :
25+ # 优先检查函数的docstring
2526 try :
2627 doc = item .function .__doc__ # type: ignore
28+ if doc :
29+ doc_str = str (doc ).strip ()
30+ if doc_str and doc_str != "main entrance, discovered by pytest" :
31+ return doc_str
2732 except AttributeError :
28- return ""
29- return str (doc ).strip () if doc else ""
33+ pass
34+
35+ # 检查类的docstring(HttpRunner测试用例)
36+ try :
37+ if hasattr (item , "cls" ) and item .cls and item .cls .__doc__ :
38+ class_doc = item .cls .__doc__ .strip ()
39+ if class_doc :
40+ return str (class_doc )
41+ except (AttributeError , TypeError ):
42+ pass
43+
44+ return ""
3045
3146
3247def _iter_markers (item : Item ) -> List [Mark ]:
Original file line number Diff line number Diff line change @@ -47,10 +47,11 @@ def test_parse_case_attributes():
4747 coding_testcase_id: 123,456
4848 """
4949 item .own_markers = []
50+ item .cls = None # 确保没有类级别的docstring
5051
5152 comment_fields = ["description" , "owner" , "coding_testcase_id" ]
5253 expected = {
53- "description" : "This is a test function" ,
54+ "description" : "This is a test function" , # 从注释中解析出的description字段值
5455 "owner" : "test_owner" ,
5556 "coding_testcase_id" : '["123", "456"]' ,
5657 "tags" : "[]" ,
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ schemaVersion: 1.0
22name : pytest
33nameZh : pytest自动化测试
44lang : python
5- version : ' 0.1.73 '
5+ version : ' 0.1.75 '
66langType : INTERPRETED
77description : |-
88 pytest是一个成熟的全功能Python测试工具,可以帮助您编写更好的程序。此测试工具允许您在TestSolar上运行pytest。
You can’t perform that action at this time.
0 commit comments