Skip to content

Commit ffcbb8a

Browse files
authored
Merge pull request #90 from OpenTestSolar/dev/support-emoji-data-drive
支持emoji数据驱动
2 parents 216c47c + c5e19c1 commit ffcbb8a

7 files changed

Lines changed: 54 additions & 3 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.35"
3+
version = "0.1.36"
44
description = "Pytest tool for TestSolar"
55
authors = [
66
{name = "asiazhang2002", email = "asiazhang2002@gmail.com"},

‎pytest/src/testsolar_pytestx/converter.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def decode_datadrive(name: str) -> str:
118118
if re.search(r"\\u\w{4}", name):
119119
name = name.encode().decode("unicode_escape")
120120

121+
if re.search(r"\\U\w{8}", name):
122+
name = name.encode().decode("unicode_escape")
123+
121124
return name
122125

123126

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
3+
@pytest.mark.parametrize("test_input", ["\U0001f604"])
4+
def test_emoji_data_drive_name(test_input):
5+
assert "bad" not in test_input
6+

‎pytest/tests/test_collector.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,25 @@ def test_collect_testcases_with_skipp_error(self):
190190

191191
self.assertEqual(len(re.Tests), 3)
192192
self.assertEqual(len(re.LoadErrors), 1)
193+
194+
def test_collect_testcases_with_emoji(self):
195+
entry = EntryParam(
196+
TaskId="aa",
197+
ProjectPath=self.testdata_dir,
198+
TestSelectors=[
199+
"test_emoji_data_drive.py",
200+
],
201+
FileReportPath="",
202+
)
203+
204+
pipe_io = io.BytesIO()
205+
collect_testcases(entry, pipe_io)
206+
pipe_io.seek(0)
207+
208+
re = read_load_result(pipe_io)
209+
210+
self.assertEqual(len(re.Tests), 1)
211+
self.assertEqual(len(re.LoadErrors), 0)
212+
self.assertEqual(
213+
re.Tests[0].Name, "test_emoji_data_drive.py?test_emoji_data_drive_name/[\U0001f604]"
214+
)

‎pytest/tests/test_executor.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,23 @@ def test_run_not_exist_selector(self):
278278
result = read_test_result(pipe_io)
279279
self.assertEqual(result.ResultType, ResultType.FAILED)
280280
self.assertEqual(result.Test.Name, "test_normal_case.py?name=not_exist")
281+
282+
def test_run_testcase_with_emoji_data_drive(self):
283+
entry = EntryParam(
284+
TaskId="aa",
285+
ProjectPath=str(self.testdata_dir),
286+
TestSelectors=[
287+
"test_emoji_data_drive.py?test_emoji_data_drive_name/[\U0001f604]",
288+
],
289+
FileReportPath="",
290+
)
291+
292+
pipe_io = io.BytesIO()
293+
run_testcases(entry, pipe_io)
294+
pipe_io.seek(0)
295+
296+
start = read_test_result(pipe_io)
297+
self.assertEqual(
298+
start.Test.Name, "test_emoji_data_drive.py?test_emoji_data_drive_name/[\U0001f604]"
299+
)
300+
self.assertEqual(start.ResultType, ResultType.RUNNING)

‎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.35'
5+
version: '0.1.36'
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)