pytest-dsl 0.11.0__py3-none-any.whl → 0.12.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.
- pytest_dsl/cli.py +89 -83
- pytest_dsl/core/http_client.py +93 -80
- pytest_dsl/keywords/http_keywords.py +90 -34
- pytest_dsl/keywords/system_keywords.py +420 -1
- pytest_dsl/remote/keyword_client.py +30 -17
- pytest_dsl/remote/keyword_server.py +18 -1
- pytest_dsl/remote/variable_bridge.py +41 -8
- {pytest_dsl-0.11.0.dist-info → pytest_dsl-0.12.0.dist-info}/METADATA +3 -3
- {pytest_dsl-0.11.0.dist-info → pytest_dsl-0.12.0.dist-info}/RECORD +13 -13
- {pytest_dsl-0.11.0.dist-info → pytest_dsl-0.12.0.dist-info}/WHEEL +0 -0
- {pytest_dsl-0.11.0.dist-info → pytest_dsl-0.12.0.dist-info}/entry_points.txt +0 -0
- {pytest_dsl-0.11.0.dist-info → pytest_dsl-0.12.0.dist-info}/licenses/LICENSE +0 -0
- {pytest_dsl-0.11.0.dist-info → pytest_dsl-0.12.0.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,8 @@
|
|
6
6
|
|
7
7
|
import logging
|
8
8
|
from typing import Any, Optional
|
9
|
-
from pytest_dsl.remote.hook_manager import register_startup_hook,
|
9
|
+
from pytest_dsl.remote.hook_manager import (register_startup_hook,
|
10
|
+
register_before_keyword_hook)
|
10
11
|
from pytest_dsl.core.yaml_vars import yaml_vars
|
11
12
|
from pytest_dsl.core.global_context import global_context
|
12
13
|
|
@@ -43,24 +44,28 @@ class VariableBridge:
|
|
43
44
|
|
44
45
|
self._bridge_installed = True
|
45
46
|
logger.info("变量桥接机制已安装")
|
47
|
+
print(f"🔗 变量桥接机制已安装,可桥接 {len(shared_variables)} 个同步变量")
|
46
48
|
|
47
49
|
def _bridged_yaml_get_variable(self, name: str) -> Optional[Any]:
|
48
50
|
"""桥接的YAML变量获取方法
|
49
51
|
|
50
52
|
优先级:
|
51
|
-
1. 原始YAML
|
53
|
+
1. 原始YAML变量(服务器本地的)
|
52
54
|
2. 客户端同步的变量
|
53
55
|
"""
|
54
56
|
# 首先尝试从原始YAML变量获取
|
55
57
|
original_value = self.original_yaml_get_variable(name)
|
56
58
|
if original_value is not None:
|
59
|
+
logger.debug(f"从原始YAML获取变量: {name}")
|
57
60
|
return original_value
|
58
61
|
|
59
62
|
# 如果原始YAML中没有,尝试从同步变量获取
|
60
63
|
if name in self.shared_variables:
|
61
64
|
logger.debug(f"从同步变量获取YAML变量: {name}")
|
65
|
+
print(f"🔗 变量桥接: 从同步变量获取 {name}")
|
62
66
|
return self.shared_variables[name]
|
63
67
|
|
68
|
+
logger.debug(f"变量 {name} 在原始YAML和同步变量中都不存在")
|
64
69
|
return None
|
65
70
|
|
66
71
|
def _bridged_global_get_variable(self, name: str) -> Any:
|
@@ -74,17 +79,20 @@ class VariableBridge:
|
|
74
79
|
# 首先尝试从原始全局上下文获取
|
75
80
|
original_value = self.original_global_get_variable(name)
|
76
81
|
if original_value is not None:
|
82
|
+
logger.debug(f"从原始全局上下文获取变量: {name}")
|
77
83
|
return original_value
|
78
|
-
except:
|
84
|
+
except Exception as e:
|
79
85
|
# 如果原始方法抛出异常,继续尝试同步变量
|
80
|
-
|
86
|
+
logger.debug(f"原始全局上下文获取变量 {name} 失败,尝试同步变量: {e}")
|
81
87
|
|
82
88
|
# 如果原始全局变量中没有,尝试从同步变量获取
|
83
89
|
if name in self.shared_variables:
|
84
90
|
logger.debug(f"从同步变量获取全局变量: {name}")
|
91
|
+
print(f"🔗 变量桥接: 从同步变量获取全局变量 {name}")
|
85
92
|
return self.shared_variables[name]
|
86
93
|
|
87
94
|
# 如果都没有找到,返回None(保持原有行为)
|
95
|
+
logger.debug(f"变量 {name} 在所有来源中都不存在")
|
88
96
|
return None
|
89
97
|
|
90
98
|
def uninstall_bridge(self):
|
@@ -113,6 +121,7 @@ def setup_variable_bridge(context):
|
|
113
121
|
if shared_variables is not None:
|
114
122
|
variable_bridge.install_bridge(shared_variables)
|
115
123
|
logger.info("变量桥接机制已在服务器启动时安装")
|
124
|
+
print(f"🔗 服务器启动时安装变量桥接机制,可桥接 {len(shared_variables)} 个变量")
|
116
125
|
else:
|
117
126
|
logger.warning("无法获取shared_variables,变量桥接机制安装失败")
|
118
127
|
|
@@ -124,11 +133,14 @@ def ensure_variable_bridge(context):
|
|
124
133
|
shared_variables = context.get('shared_variables')
|
125
134
|
keyword_name = context.get('keyword_name')
|
126
135
|
|
127
|
-
#
|
128
|
-
if
|
136
|
+
# 对所有关键字进行调试日志(如果有同步变量)
|
137
|
+
if shared_variables and len(shared_variables) > 0:
|
129
138
|
synced_count = len(shared_variables)
|
130
|
-
|
131
|
-
|
139
|
+
logger.debug(f"关键字 {keyword_name} 执行前,可用同步变量数量: {synced_count}")
|
140
|
+
|
141
|
+
# 对重要关键字显示详细信息
|
142
|
+
if keyword_name in ['HTTP请求', '数据库查询', 'API调用']:
|
143
|
+
print(f"🔗 关键字 {keyword_name} 可访问 {synced_count} 个同步变量")
|
132
144
|
|
133
145
|
|
134
146
|
def get_synced_variable(name: str) -> Optional[Any]:
|
@@ -162,3 +174,24 @@ def has_synced_variable(name: str) -> bool:
|
|
162
174
|
是否存在该同步变量
|
163
175
|
"""
|
164
176
|
return name in variable_bridge.shared_variables
|
177
|
+
|
178
|
+
|
179
|
+
def get_all_accessible_variables() -> dict:
|
180
|
+
"""获取所有可访问的变量(包括原始变量和同步变量)
|
181
|
+
|
182
|
+
Returns:
|
183
|
+
所有可访问变量的字典
|
184
|
+
"""
|
185
|
+
all_vars = {}
|
186
|
+
|
187
|
+
# 添加原始YAML变量
|
188
|
+
try:
|
189
|
+
if hasattr(yaml_vars, '_variables'):
|
190
|
+
all_vars.update(yaml_vars._variables)
|
191
|
+
except Exception as e:
|
192
|
+
logger.warning(f"获取原始YAML变量失败: {e}")
|
193
|
+
|
194
|
+
# 添加同步变量(会覆盖同名的原始变量)
|
195
|
+
all_vars.update(variable_bridge.shared_variables)
|
196
|
+
|
197
|
+
return all_vars
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pytest-dsl
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.0
|
4
4
|
Summary: A DSL testing framework based on pytest
|
5
5
|
Author: Chen Shuanglin
|
6
6
|
License: MIT
|
@@ -1038,7 +1038,7 @@ jobs:
|
|
1038
1038
|
|
1039
1039
|
- name: Run tests
|
1040
1040
|
run: |
|
1041
|
-
pytest
|
1041
|
+
pytest test_runner.py --alluredir=allure-results
|
1042
1042
|
|
1043
1043
|
- name: Generate report
|
1044
1044
|
uses: simple-elf/allure-report-action@master
|
@@ -1097,7 +1097,7 @@ CMD ["pytest-dsl", "tests/", "--yaml-vars", "config/prod.yaml"]
|
|
1097
1097
|
### 适用场景
|
1098
1098
|
|
1099
1099
|
- **API接口测试** - 完整的HTTP测试支持
|
1100
|
-
-
|
1100
|
+
- **分布式测试** - 跨服务调用、服务间通信和分布式系统测试
|
1101
1101
|
- **回归测试** - 数据驱动和批量执行
|
1102
1102
|
- **集成测试** - 跨系统测试协调
|
1103
1103
|
- **性能测试** - 结合其他工具进行性能测试
|
@@ -1,5 +1,5 @@
|
|
1
1
|
pytest_dsl/__init__.py,sha256=FzwXGvmuvMhRBKxvCdh1h-yJ2wUOnDxcTbU4Nt5fHn8,301
|
2
|
-
pytest_dsl/cli.py,sha256=
|
2
|
+
pytest_dsl/cli.py,sha256=clpvDtQ18tJHl0DUKhoAfCNROE3TB_t59z0fOn5VL9M,33404
|
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
|
@@ -12,7 +12,7 @@ pytest_dsl/core/custom_keyword_manager.py,sha256=UdlGUc_mT8hIwmU7LVf4wJLG-geChwY
|
|
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
|
-
pytest_dsl/core/http_client.py,sha256=
|
15
|
+
pytest_dsl/core/http_client.py,sha256=hdx8gI4JCmq1-96pbiKeyKzSQUzPAi08cRNmljiPQmY,15536
|
16
16
|
pytest_dsl/core/http_request.py,sha256=nGMlx0mFc7rDLIdp9GJ3e09OQH3ryUA56yJdRZ99dOQ,57445
|
17
17
|
pytest_dsl/core/keyword_manager.py,sha256=hoNXHQcumnufPRUobnY0mnku4CHxSg2amwPFby4gQEs,7643
|
18
18
|
pytest_dsl/core/lexer.py,sha256=WaLzt9IhtHiA90Fg2WGgfVztveCUhtgxzANBaEiy-F8,4347
|
@@ -57,17 +57,17 @@ pytest_dsl/examples/quickstart/loops.auto,sha256=ZNZ6qP636v8QMY8QRyTUBB43gWCsqHb
|
|
57
57
|
pytest_dsl/keywords/__init__.py,sha256=5aiyPU_t1UiB2MEZ6M9ffOKnV1mFT_2YHxnZvyWaBNI,372
|
58
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=
|
61
|
-
pytest_dsl/keywords/system_keywords.py,sha256=
|
60
|
+
pytest_dsl/keywords/http_keywords.py,sha256=z2Brqj1Mkufa_PlZZNwfKuYqkgJhnjsZw-7YNnbt2N4,27302
|
61
|
+
pytest_dsl/keywords/system_keywords.py,sha256=hjsACYER87rseSj4thBFnjDqe6At5hBT4Gjifj4ulDE,24470
|
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=
|
65
|
-
pytest_dsl/remote/keyword_server.py,sha256=
|
66
|
-
pytest_dsl/remote/variable_bridge.py,sha256=
|
64
|
+
pytest_dsl/remote/keyword_client.py,sha256=BL80MOaLroUi0v-9sLtkJ55g1R0Iw9SE1k11Ifwqx-I,17292
|
65
|
+
pytest_dsl/remote/keyword_server.py,sha256=vGIE3Bhh461xX_u1U-Cf5nrWL2GQFYdtQdcMWfFIYgE,22320
|
66
|
+
pytest_dsl/remote/variable_bridge.py,sha256=dv-d3Gq9ttvvrXM1fdlLtoSOPB6vRp0_GBOwX4wvcy8,7121
|
67
67
|
pytest_dsl/templates/keywords_report.html,sha256=7x84iq6hi08nf1iQ95jZ3izcAUPx6JFm0_8xS85CYws,31241
|
68
|
-
pytest_dsl-0.
|
69
|
-
pytest_dsl-0.
|
70
|
-
pytest_dsl-0.
|
71
|
-
pytest_dsl-0.
|
72
|
-
pytest_dsl-0.
|
73
|
-
pytest_dsl-0.
|
68
|
+
pytest_dsl-0.12.0.dist-info/licenses/LICENSE,sha256=Rguy8cb9sYhK6cmrBdXvwh94rKVDh2tVZEWptsHIsVM,1071
|
69
|
+
pytest_dsl-0.12.0.dist-info/METADATA,sha256=M9J5LQQtA4aCQ3KqCRxjgiDcnZnMc_f_0Yctx91ZpvI,29655
|
70
|
+
pytest_dsl-0.12.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
71
|
+
pytest_dsl-0.12.0.dist-info/entry_points.txt,sha256=PLOBbH02OGY1XR1JDKIZB1Em87loUvbgMRWaag-5FhY,204
|
72
|
+
pytest_dsl-0.12.0.dist-info/top_level.txt,sha256=4CrSx4uNqxj7NvK6k1y2JZrSrJSzi-UvPZdqpUhumWM,11
|
73
|
+
pytest_dsl-0.12.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|