Skip to content

Commit 397774d

Browse files
authored
Merge pull request #95 from OpenTestSolar/dev/do-not-sort-load-result
取消对加载结果的排序
2 parents d2eaa8f + 106427e commit 397774d

6 files changed

Lines changed: 20 additions & 14 deletions

File tree

‎pytest/requirements.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# This file was autogenerated via `uv export`.
1+
# This file was autogenerated by uv via the following command:
2+
# uv export --no-hashes --no-dev --locked
23
colorama==0.4.6 ; sys_platform == 'win32'
34
coverage==7.2.7
45
dacite==1.8.1

‎pytest/src/testsolar_pytestx/collector.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def collect_testcases(
138138
# 增加额外功能,方便外部接入
139139
if extra_load_function:
140140
extra_load_function(entry_param.ProjectPath, load_result, case_drive_records)
141-
load_result.Tests.sort(key=lambda x: x.Name)
142141

143142
for k, v in my_plugin.errors.items():
144143
load_result.LoadErrors.append(
@@ -148,8 +147,6 @@ def collect_testcases(
148147
)
149148
)
150149

151-
load_result.LoadErrors.sort(key=lambda x: x.name)
152-
153150
print(f"[Load] collect testcase count: {len(load_result.Tests)}")
154151
print(f"[Load] collect load error count: {len(load_result.LoadErrors)}")
155152

‎pytest/tests/test_collector.py‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def test_collect_testcases_when_selector_is_valid(self):
3535

3636
self.assertEqual(len(re.Tests), 6)
3737
self.assertEqual(len(re.LoadErrors), 2)
38-
38+
re.Tests.sort(key=lambda x: x.Name)
39+
re.LoadErrors.sort(key=lambda x: x.name)
3940
self.assertEqual(re.Tests[0].Name, "aa/bb/cc/test_in_sub_class.py?TestCompute/test_add")
4041
self.assertEqual(re.Tests[1].Name, "test_data_drive.py?test_eval/%5B2%2B4-6%5D")
4142
self.assertEqual(re.Tests[2].Name, "test_data_drive.py?test_eval/%5B3%2B5-8%5D")
@@ -80,7 +81,8 @@ def test_collect_testcases_when_select_not_valid(self):
8081
pipe_io.seek(0)
8182

8283
re = read_load_result(pipe_io)
83-
84+
re.Tests.sort(key=lambda x: x.Name)
85+
re.LoadErrors.sort(key=lambda x: x.name)
8486
self.assertEqual(len(re.Tests), 4)
8587
self.assertEqual(len(re.LoadErrors), 1)
8688
self.assertIn("test_not_exist.py does not exist, SKIP it", re.LoadErrors[0].message)
@@ -100,7 +102,8 @@ def test_collect_testcases_with_utf8_chars(self):
100102
pipe_io.seek(0)
101103

102104
re = read_load_result(pipe_io)
103-
105+
re.Tests.sort(key=lambda x: x.Name)
106+
re.LoadErrors.sort(key=lambda x: x.name)
104107
self.assertEqual(len(re.Tests), 3)
105108
self.assertEqual(len(re.LoadErrors), 0)
106109

@@ -139,7 +142,8 @@ def loader_extend(param_1: str, param_2: LoadResult, param_3: Dict[str, List[str
139142
pipe_io.seek(0)
140143

141144
re = read_load_result(pipe_io)
142-
145+
re.Tests.sort(key=lambda x: x.Name)
146+
re.LoadErrors.sort(key=lambda x: x.name)
143147
self.assertEqual(len(re.Tests), 1)
144148
self.assertEqual(len(re.LoadErrors), 0)
145149

@@ -169,7 +173,8 @@ def test_collect_testcases_when_testcase_not_exist(self):
169173
pipe_io.seek(0)
170174

171175
re = read_load_result(pipe_io)
172-
176+
re.Tests.sort(key=lambda x: x.Name)
177+
re.LoadErrors.sort(key=lambda x: x.name)
173178
self.assertEqual(len(re.LoadErrors), 1)
174179

175180
self.assertEqual(
@@ -193,7 +198,8 @@ def test_collect_testcases_with_skipp_error(self):
193198
pipe_io.seek(0)
194199

195200
re = read_load_result(pipe_io)
196-
201+
re.Tests.sort(key=lambda x: x.Name)
202+
re.LoadErrors.sort(key=lambda x: x.name)
197203
self.assertEqual(len(re.Tests), 3)
198204
self.assertEqual(len(re.LoadErrors), 1)
199205

@@ -212,7 +218,8 @@ def test_collect_testcases_with_emoji(self):
212218
pipe_io.seek(0)
213219

214220
re = read_load_result(pipe_io)
215-
221+
re.Tests.sort(key=lambda x: x.Name)
222+
re.LoadErrors.sort(key=lambda x: x.name)
216223
self.assertEqual(len(re.Tests), 1)
217224
self.assertEqual(len(re.LoadErrors), 0)
218225
self.assertEqual(

‎pytest/tests/test_load.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def test_collect_testcases_from_args(self):
2020

2121
pipe_io.seek(0)
2222
re = read_load_result(pipe_io)
23-
23+
re.Tests.sort(key=lambda x: x.Name)
24+
re.LoadErrors.sort(key=lambda x: x.name)
2425
self.assertEqual(len(re.Tests), 7)
2526
self.assertEqual(
2627
re.Tests[4].Name,

‎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.39'
5+
version: '0.1.40'
66
langType: INTERPRETED
77
description: |-
88
pytest是一个成熟的全功能Python测试工具,可以帮助您编写更好的程序。此测试工具允许您在TestSolar上运行pytest。

‎pytest/uv.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)