Skip to content

Commit c5f4d09

Browse files
authored
Merge pull request #107 from OpenTestSolar/bugfix/pytest-fix-parse-selector-bug
修复解析selector存在的bug
2 parents 637ab3f + 6c2cec8 commit c5f4d09

5 files changed

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

‎pytest/src/testsolar_pytestx/converter.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,25 @@ def selector_to_pytest(test_selector: str) -> str:
1111
"""translate from test selector format to pytest format"""
1212
path, _, testcase = test_selector.partition("?")
1313

14-
if not testcase:
14+
if not testcase: # tests/hello_test.py
1515
return path
1616

1717
if "&" in testcase:
1818
testcase_attrs = testcase.split("&")
1919
for attr in testcase_attrs:
20-
if "name=" in attr:
20+
if "name=" in attr: # tests/hello_test.py?name=xxxTest&tag=prod
2121
testcase = attr[5:]
2222
break
23-
elif "=" not in attr:
23+
elif "=" not in attr: # tests/hello_test.py?xxxTest&
2424
testcase = attr
2525
break
26+
else: # tests/hello_test.py?test_hello_world&tag=prod
27+
return path
2628
else:
27-
if testcase.startswith("name="):
29+
if testcase.startswith("name="): # tests/hello_test.py?name=xxxTest
2830
testcase = testcase[5:]
31+
elif "=" in testcase: # tests/hello_test.py?tag=prod
32+
return path
2933

3034
case, datadrive = extract_case_and_datadrive(testcase)
3135

‎pytest/tests/test_converter.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ def test_selector_to_pytest_without_datadrive(self):
1818
re = selector_to_pytest("/data/tests/tests/test_data_drive_zh_cn.py?aa/bb/test_include")
1919
self.assertEqual(re, "/data/tests/tests/test_data_drive_zh_cn.py::aa::bb::test_include")
2020

21+
def test_selector_to_pytest_with_tag(self):
22+
re = selector_to_pytest("hello_test?tag=ready&tag=-skip")
23+
self.assertEqual(re, "hello_test")
24+
re = selector_to_pytest("hello_test?tag=ready")
25+
self.assertEqual(re, "hello_test")
26+
re = selector_to_pytest("hello_test?name=HelloTest&tag=ready")
27+
self.assertEqual(re, "hello_test::HelloTest")
28+
re = selector_to_pytest("hello_test?HelloTest&tag=ready")
29+
self.assertEqual(re, "hello_test::HelloTest")
30+
2131
def test_selector_to_pytest_with_datadrive(self):
2232
re = selector_to_pytest(
2333
"/data/tests/tests/test_data_drive_zh_cn.py?aa/bb/test_include/[#?/-#?^$%!]"

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