pytest-dsl 0.9.1__py3-none-any.whl → 0.11.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-dsl
3
- Version: 0.9.1
3
+ Version: 0.11.0
4
4
  Summary: A DSL testing framework based on pytest
5
5
  Author: Chen Shuanglin
6
6
  License: MIT
@@ -27,6 +27,7 @@ Requires-Dist: requests>=2.28.0
27
27
  Requires-Dist: lxml>=4.9.0
28
28
  Requires-Dist: jsonschema>=4.17.0
29
29
  Requires-Dist: pytz>=2023.3
30
+ Requires-Dist: Jinja2>=3.0.0
30
31
  Dynamic: license-file
31
32
 
32
33
  # pytest-dsl: 强大的关键字驱动测试自动化框架
@@ -42,11 +43,12 @@ pytest-dsl是一个革命性的关键字驱动测试框架,基于pytest构建
42
43
  ## ✨ 核心特性
43
44
 
44
45
  - 🎯 **门槛上手低** - 自然语言风格,只需少量编程基础
45
- - 🔧 **高度可扩展** - 轻松创建自定义关键字
46
+ - 🔧 **高度可扩展** - 轻松创建自定义关键字,支持参数默认值
46
47
  - 🌐 **分布式执行** - 支持远程关键字调用
47
48
  - 🔄 **无缝集成** - 完美兼容pytest生态
48
49
  - 📊 **丰富报告** - 集成Allure测试报告
49
50
  - 🛡️ **企业级** - 支持变量管理、环境隔离
51
+ - ⚡ **智能简化** - 参数默认值让DSL更加简洁易读
50
52
 
51
53
  ## 🚀 5分钟快速开始
52
54
 
@@ -850,17 +852,19 @@ def database_query(**kwargs):
850
852
 
851
853
  @keyword_manager.register('发送邮件', [
852
854
  {'name': '收件人', 'mapping': 'to_email', 'description': '收件人邮箱'},
853
- {'name': '主题', 'mapping': 'subject', 'description': '邮件主题'},
854
- {'name': '内容', 'mapping': 'content', 'description': '邮件内容'}
855
+ {'name': '主题', 'mapping': 'subject', 'description': '邮件主题', 'default': '测试邮件'},
856
+ {'name': '内容', 'mapping': 'content', 'description': '邮件内容', 'default': '这是一封测试邮件'},
857
+ {'name': '优先级', 'mapping': 'priority', 'description': '邮件优先级', 'default': 'normal'}
855
858
  ])
856
859
  def send_email(**kwargs):
857
860
  """发送邮件通知"""
858
861
  to_email = kwargs.get('to_email')
859
- subject = kwargs.get('subject')
860
- content = kwargs.get('content')
862
+ subject = kwargs.get('subject', '测试邮件')
863
+ content = kwargs.get('content', '这是一封测试邮件')
864
+ priority = kwargs.get('priority', 'normal')
861
865
 
862
866
  # 实现邮件发送逻辑
863
- print(f"发送邮件到 {to_email}: {subject}")
867
+ print(f"发送邮件到 {to_email}: {subject} (优先级: {priority})")
864
868
 
865
869
  return True
866
870
  ```
@@ -874,10 +878,71 @@ def send_email(**kwargs):
874
878
  users = [数据库查询], 查询语句: "SELECT * FROM users WHERE active = 1"
875
879
  [打印], 内容: "查询到 ${len(users)} 个活跃用户"
876
880
 
877
- # 发送测试报告邮件
878
- [发送邮件], 收件人: "admin@example.com", 主题: "测试报告", 内容: "测试已完成"
881
+ # 发送测试报告邮件 - 使用默认值
882
+ [发送邮件], 收件人: "admin@example.com" # 主题和内容使用默认值
883
+
884
+ # 发送自定义邮件 - 覆盖默认值
885
+ [发送邮件], 收件人: "dev@example.com", 主题: "部署完成", 内容: "系统已成功部署到生产环境"
886
+ ```
887
+
888
+ ### 5. 参数默认值功能 🆕
889
+
890
+ pytest-dsl 现在支持为关键字参数设置默认值,让DSL编写更加简洁:
891
+
892
+ #### 定义带默认值的关键字
893
+
894
+ ```python
895
+ from pytest_dsl.core.keyword_manager import keyword_manager
896
+
897
+ @keyword_manager.register('HTTP请求', [
898
+ {'name': '地址', 'mapping': 'url', 'description': '请求地址'},
899
+ {'name': '方法', 'mapping': 'method', 'description': 'HTTP方法', 'default': 'GET'},
900
+ {'name': '超时', 'mapping': 'timeout', 'description': '超时时间(秒)', 'default': 30},
901
+ {'name': '重试次数', 'mapping': 'retries', 'description': '重试次数', 'default': 3},
902
+ {'name': '验证SSL', 'mapping': 'verify_ssl', 'description': '是否验证SSL证书', 'default': True}
903
+ ])
904
+ def http_request(**kwargs):
905
+ """HTTP请求关键字,支持默认值"""
906
+ url = kwargs.get('url')
907
+ method = kwargs.get('method', 'GET') # 默认值也会自动应用
908
+ timeout = kwargs.get('timeout', 30)
909
+ retries = kwargs.get('retries', 3)
910
+ verify_ssl = kwargs.get('verify_ssl', True)
911
+
912
+ # 执行HTTP请求逻辑
913
+ return {"status": "success", "method": method, "url": url}
879
914
  ```
880
915
 
916
+ #### 在DSL中使用默认值
917
+
918
+ ```python
919
+ @name: "默认值功能演示"
920
+
921
+ # 只传递必需参数,其他使用默认值
922
+ response1 = [HTTP请求], 地址: "https://api.example.com/users"
923
+ # 等价于:方法: "GET", 超时: 30, 重试次数: 3, 验证SSL: True
924
+
925
+ # 部分覆盖默认值
926
+ response2 = [HTTP请求], 地址: "https://api.example.com/users", 方法: "POST", 超时: 60
927
+ # 只覆盖方法和超时,重试次数和SSL验证仍使用默认值
928
+
929
+ # 内置关键字也支持默认值
930
+ random_num = [生成随机数] # 使用默认范围 0-100,整数
931
+ custom_num = [生成随机数], 最大值: 50 # 只修改最大值,其他保持默认
932
+
933
+ # 生成随机字符串
934
+ default_string = [生成随机字符串] # 长度8,字母数字混合
935
+ custom_string = [生成随机字符串], 长度: 12, 类型: "letters" # 自定义长度和类型
936
+ ```
937
+
938
+ #### 默认值的优势
939
+
940
+ - **🎯 简化调用** - 只需传递关键参数,常用配置自动应用
941
+ - **🔧 灵活覆盖** - 可选择性地覆盖任何默认值
942
+ - **📖 提高可读性** - DSL更加简洁,重点突出
943
+ - **🛡️ 减少错误** - 避免重复配置常用参数
944
+ - **🌐 远程支持** - 远程关键字也完整支持默认值功能
945
+
881
946
  #### 支持远程模式的关键字
882
947
 
883
948
  ```python
@@ -1037,20 +1102,6 @@ CMD ["pytest-dsl", "tests/", "--yaml-vars", "config/prod.yaml"]
1037
1102
  - **集成测试** - 跨系统测试协调
1038
1103
  - **性能测试** - 结合其他工具进行性能测试
1039
1104
 
1040
- ## 🤝 贡献与支持
1041
-
1042
- 我们欢迎您的贡献和反馈!
1043
-
1044
- - 🐛 [报告问题](https://github.com/your-repo/pytest-dsl/issues)
1045
- - 💡 [功能建议](https://github.com/your-repo/pytest-dsl/discussions)
1046
- - 🔧 [提交PR](https://github.com/your-repo/pytest-dsl/pulls)
1047
-
1048
- ## 📄 许可证
1049
-
1050
- MIT License - 详见 [LICENSE](LICENSE) 文件
1051
-
1052
- ---
1053
-
1054
1105
  ## 📋 示例验证
1055
1106
 
1056
1107
  本README.md中的大部分示例都已经过验证,确保可以正常运行。验证示例位于 `examples/readme_validation/` 目录中。
@@ -1086,3 +1137,18 @@ pytest-dsl api_basic.dsl
1086
1137
  ---
1087
1138
 
1088
1139
  🚀 **开始使用pytest-dsl,让测试自动化变得简单而强大!**
1140
+
1141
+
1142
+ ## 🤝 贡献与支持
1143
+
1144
+ 我们欢迎您的贡献和反馈!
1145
+
1146
+ - 🐛 [报告问题](https://github.com/felix-1991/pytest-dsl/issues)
1147
+ - 💡 [功能建议](https://github.com/felix-1991/pytest-dsl/discussions)
1148
+ - 🔧 [提交PR](https://github.com/felix-1991/pytest-dsl/pulls)
1149
+
1150
+ ## 📄 许可证
1151
+
1152
+ MIT License - 详见 [LICENSE](LICENSE) 文件
1153
+
1154
+ ---
@@ -1,5 +1,5 @@
1
1
  pytest_dsl/__init__.py,sha256=FzwXGvmuvMhRBKxvCdh1h-yJ2wUOnDxcTbU4Nt5fHn8,301
2
- pytest_dsl/cli.py,sha256=x3zSHJqAGUNPUsJfhFRzVVwRE0zM02Lcr2bx_V8v4YA,15806
2
+ pytest_dsl/cli.py,sha256=KBuSFwsdbRULxsVscR-2Hffoz-hwSLpJGSsxVnbqtbI,33895
3
3
  pytest_dsl/conftest_adapter.py,sha256=cevEb0oEZKTZfUrGe1-CmkFByxKhUtjuurBJP7kpLc0,149
4
4
  pytest_dsl/main_adapter.py,sha256=pUIPN_EzY3JCDlYK7yF_OeLDVqni8vtG15G7gVzPJXg,181
5
5
  pytest_dsl/plugin.py,sha256=MEQcdK0xdxwxCxPEDLNHX_kGF9Jc7bNxlNi4mx588DU,1190
@@ -8,17 +8,17 @@ pytest_dsl/core/auth_provider.py,sha256=IZfXXrr4Uuc8QHwRPvhHSzNa2fwrqhjYts1xh78D
8
8
  pytest_dsl/core/auto_decorator.py,sha256=9Mga-GB4AzV5nkB6zpfaq8IuHa0KOH8LlFvnWyH_tnU,6623
9
9
  pytest_dsl/core/auto_directory.py,sha256=egyTnVxtGs4P75EIivRauLRPJfN9aZpoGVvp_Ma72AM,2714
10
10
  pytest_dsl/core/context.py,sha256=fXpVQon666Lz_PCexjkWMBBr-Xcd1SkDMp2vHar6eIs,664
11
- pytest_dsl/core/custom_keyword_manager.py,sha256=Y3MftSklqGSS3FfeZjmyfcGHfQw6FrhFTwgS_O8zQh4,7606
11
+ pytest_dsl/core/custom_keyword_manager.py,sha256=UdlGUc_mT8hIwmU7LVf4wJLG-geChwYgvcFM-KtPvJA,7512
12
12
  pytest_dsl/core/dsl_executor.py,sha256=aEEfocFCFxNDN1puBFhQzL5fzw9eZx8BAyYJI5XSt4Y,30472
13
13
  pytest_dsl/core/dsl_executor_utils.py,sha256=cFoR2p3qQ2pb-UhkoefleK-zbuFqf0aBLh2Rlp8Ebs4,2180
14
14
  pytest_dsl/core/global_context.py,sha256=NcEcS2V61MT70tgAsGsFWQq0P3mKjtHQr1rgT3yTcyY,3535
15
15
  pytest_dsl/core/http_client.py,sha256=1AHqtM_fkXf8JrM0ljMsJwUkyt-ysjR16NoyCckHfGc,15810
16
16
  pytest_dsl/core/http_request.py,sha256=nGMlx0mFc7rDLIdp9GJ3e09OQH3ryUA56yJdRZ99dOQ,57445
17
- pytest_dsl/core/keyword_manager.py,sha256=FtPsXlI7PxvVQMJfDN_nQYvRhkag5twvaHXjELQsCEo,4068
17
+ pytest_dsl/core/keyword_manager.py,sha256=hoNXHQcumnufPRUobnY0mnku4CHxSg2amwPFby4gQEs,7643
18
18
  pytest_dsl/core/lexer.py,sha256=WaLzt9IhtHiA90Fg2WGgfVztveCUhtgxzANBaEiy-F8,4347
19
19
  pytest_dsl/core/parser.py,sha256=xxy6yC6NdwHxln200aIuaWWN3w44uI8kkNlw8PTVpYI,11855
20
20
  pytest_dsl/core/parsetab.py,sha256=aN-2RRTr3MSbMyfe-9zOj_t96Xu84avE29GWqH6nqmg,31472
21
- pytest_dsl/core/plugin_discovery.py,sha256=vcO4-I9o4GSffLDd36idhOz6XUI1K7JhOQWwhpCDoNw,6523
21
+ pytest_dsl/core/plugin_discovery.py,sha256=3pt3EXJ7EPF0rkUlyDZMVHkIiTy2vicdIIQJkrHXZjY,8305
22
22
  pytest_dsl/core/utils.py,sha256=q0AMdw5HO33JvlA3UJeQ7IXh1Z_8K1QlwiM1_yiITrU,5350
23
23
  pytest_dsl/core/variable_utils.py,sha256=sx5DFZAO_syi0E_0ACisiZUQL9yxGeOfNmMtV6w9V3E,13947
24
24
  pytest_dsl/core/yaml_loader.py,sha256=IOzRP3iEaVJ-4UiZGkuwy5VAD8_pWQjKHD0tZhwIGb8,4858
@@ -55,18 +55,19 @@ pytest_dsl/examples/quickstart/api_basics.auto,sha256=SrDRBASqy5ZMXnmfczuKNCXoTi
55
55
  pytest_dsl/examples/quickstart/assertions.auto,sha256=FWrwod3L8oxuKCnA-lnVO2fzs5bZsXWaVqd6zehKrzw,859
56
56
  pytest_dsl/examples/quickstart/loops.auto,sha256=ZNZ6qP636v8QMY8QRyTUBB43gWCsqHbpPQw2RqamvOk,516
57
57
  pytest_dsl/keywords/__init__.py,sha256=5aiyPU_t1UiB2MEZ6M9ffOKnV1mFT_2YHxnZvyWaBNI,372
58
- pytest_dsl/keywords/assertion_keywords.py,sha256=WOCGP7WX2wZ6mQPDGmi38LWdG2NaThHoNU54xc8VpxI,23027
58
+ pytest_dsl/keywords/assertion_keywords.py,sha256=obW06H_3AizsvEM_9VE2JVuwvgrNVqP1kUTDd3U1SMk,23240
59
59
  pytest_dsl/keywords/global_keywords.py,sha256=4yw5yeXoGf_4W26F39EA2Pp-mH9GiKGy2jKgFO9a_wM,2509
60
- pytest_dsl/keywords/http_keywords.py,sha256=DY1SvUgOziN6Ga-QgE0q4XFd2qGGwvbv1B_k2gTdPLw,25554
61
- pytest_dsl/keywords/system_keywords.py,sha256=n_jRrMvSv2v6Pm_amokfyLNVOLYP7CFWbBE3_dlO7h4,11299
60
+ pytest_dsl/keywords/http_keywords.py,sha256=B2IoWZjmAk0bQf1o5hHhHEDHpAl010PrDVA4iJ1mLk0,25605
61
+ pytest_dsl/keywords/system_keywords.py,sha256=e65Mzyt56FYmw0vHegajLUSLeEYVI9Y-WSB1h6SKKLo,12089
62
62
  pytest_dsl/remote/__init__.py,sha256=syRSxTlTUfdAPleJnVS4MykRyEN8_SKiqlsn6SlIK8k,120
63
63
  pytest_dsl/remote/hook_manager.py,sha256=0hwRKP8yhcnfAnrrnZGVT-S0TBgo6c0A4qO5XRpvV1U,4899
64
- pytest_dsl/remote/keyword_client.py,sha256=Zem86qW6TudPAiiqU8wAFQeCoBl5urPRiAhFDPkAGgQ,15618
65
- pytest_dsl/remote/keyword_server.py,sha256=5nKLUIqgAVJoLL2t2dHaJb9S95z4K3UusSMEBylU6X4,20549
64
+ pytest_dsl/remote/keyword_client.py,sha256=doXmg2Aenx9SclKtd5bT3n-DkxGK3MnMRwn4dpdug8s,16848
65
+ pytest_dsl/remote/keyword_server.py,sha256=7eRBHXyTC2AyXBeXMHOYLjgj570ioiAhnq4CuEnkak4,21386
66
66
  pytest_dsl/remote/variable_bridge.py,sha256=KG2xTZcUExb8kNL-rR-IPFJmYGfo7ciE4W7xzet59sw,5520
67
- pytest_dsl-0.9.1.dist-info/licenses/LICENSE,sha256=Rguy8cb9sYhK6cmrBdXvwh94rKVDh2tVZEWptsHIsVM,1071
68
- pytest_dsl-0.9.1.dist-info/METADATA,sha256=tmPXjA1YZtuduO_Fus6vujf1vMOYxx3L2n7c7ZV4oyc,26712
69
- pytest_dsl-0.9.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
70
- pytest_dsl-0.9.1.dist-info/entry_points.txt,sha256=PLOBbH02OGY1XR1JDKIZB1Em87loUvbgMRWaag-5FhY,204
71
- pytest_dsl-0.9.1.dist-info/top_level.txt,sha256=4CrSx4uNqxj7NvK6k1y2JZrSrJSzi-UvPZdqpUhumWM,11
72
- pytest_dsl-0.9.1.dist-info/RECORD,,
67
+ pytest_dsl/templates/keywords_report.html,sha256=7x84iq6hi08nf1iQ95jZ3izcAUPx6JFm0_8xS85CYws,31241
68
+ pytest_dsl-0.11.0.dist-info/licenses/LICENSE,sha256=Rguy8cb9sYhK6cmrBdXvwh94rKVDh2tVZEWptsHIsVM,1071
69
+ pytest_dsl-0.11.0.dist-info/METADATA,sha256=Xr_eldwYrWr12X9fQMl1BN9UlqJrT0UOw9AiQoLgQC4,29642
70
+ pytest_dsl-0.11.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
71
+ pytest_dsl-0.11.0.dist-info/entry_points.txt,sha256=PLOBbH02OGY1XR1JDKIZB1Em87loUvbgMRWaag-5FhY,204
72
+ pytest_dsl-0.11.0.dist-info/top_level.txt,sha256=4CrSx4uNqxj7NvK6k1y2JZrSrJSzi-UvPZdqpUhumWM,11
73
+ pytest_dsl-0.11.0.dist-info/RECORD,,