pytest-dsl 0.4.0__tar.gz → 0.6.0__tar.gz
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-0.4.0/pytest_dsl.egg-info → pytest_dsl-0.6.0}/PKG-INFO +266 -15
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/README.md +265 -14
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pyproject.toml +2 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/cli.py +28 -33
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/auto_decorator.py +72 -53
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/auto_directory.py +8 -5
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/dsl_executor.py +211 -53
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/http_request.py +272 -221
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/lexer.py +14 -13
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/parser.py +27 -8
- pytest_dsl-0.6.0/pytest_dsl/core/parsetab.py +114 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/plugin_discovery.py +1 -8
- pytest_dsl-0.6.0/pytest_dsl/core/yaml_loader.py +139 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/assert/assertion_example.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/assert/boolean_test.auto +2 -2
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/assert/expression_test.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/custom/test_advanced_keywords.auto +2 -2
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/custom/test_custom_keywords.auto +2 -2
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/custom/test_default_values.auto +2 -2
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/file_reference_test.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/http_advanced.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/http_example.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/http_length_test.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/http_retry_assertions.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/http_retry_assertions_enhanced.auto +2 -2
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/http_with_yaml.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/quickstart/api_basics.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/quickstart/assertions.auto +1 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/quickstart/loops.auto +2 -2
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/keywords/assertion_keywords.py +76 -62
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/keywords/global_keywords.py +43 -4
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/keywords/http_keywords.py +141 -139
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0/pytest_dsl.egg-info}/PKG-INFO +266 -15
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl.egg-info/SOURCES.txt +6 -1
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl.egg-info/entry_points.txt +1 -0
- pytest_dsl-0.6.0/tests/test_end_to_end_seamless.py +239 -0
- pytest_dsl-0.6.0/tests/test_http_assertions_extractors.py +378 -0
- pytest_dsl-0.6.0/tests/test_seamless_variable_sync.py +197 -0
- pytest_dsl-0.6.0/tests/test_variable_sync.py +142 -0
- pytest_dsl-0.6.0/tests/test_variable_sync_demo.py +136 -0
- pytest_dsl-0.4.0/pytest_dsl/core/parsetab.py +0 -109
- pytest_dsl-0.4.0/pytest_dsl/core/yaml_loader.py +0 -62
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/LICENSE +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/MANIFEST.in +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/__init__.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/conftest_adapter.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/__init__.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/auth_provider.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/context.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/custom_keyword_manager.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/dsl_executor_utils.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/global_context.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/http_client.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/keyword_manager.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/utils.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/variable_utils.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/core/yaml_vars.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/docs/custom_keywords.md +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/__init__.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/__init__.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/builtin_auth_test.auto +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/new_retry_test.auto +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/retry_assertions_only.auto +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/retry_config_only.auto +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/retry_debug.auto +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/retry_with_fix.auto +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/simple_retry.auto +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/http/vars.yaml +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/test_assert.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/test_custom_keyword.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/test_http.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/examples/test_quickstart.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/keywords/__init__.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/keywords/system_keywords.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/main_adapter.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/parsetab.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl/plugin.py +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl.egg-info/dependency_links.txt +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl.egg-info/requires.txt +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/pytest_dsl.egg-info/top_level.txt +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/setup.cfg +0 -0
- {pytest_dsl-0.4.0 → pytest_dsl-0.6.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pytest-dsl
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.6.0
|
4
4
|
Summary: A DSL testing framework based on pytest
|
5
5
|
Author: Chen Shuanglin
|
6
6
|
License: MIT
|
@@ -60,7 +60,7 @@ for i in range(1, 3) do
|
|
60
60
|
[打印],内容: "循环次数: ${i}"
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
teardown do
|
64
64
|
[打印],内容: "测试完成!"
|
65
65
|
end
|
66
66
|
```
|
@@ -147,14 +147,14 @@ pytest-dsl允许在DSL文件中直接定义自定义关键字,类似于编程
|
|
147
147
|
@name: "自定义关键字示例"
|
148
148
|
|
149
149
|
# 定义一个简单的关键字(函数)
|
150
|
-
|
150
|
+
function 拼接字符串 (前缀, 后缀="默认后缀") do
|
151
151
|
# 直接使用关键字参数
|
152
152
|
[打印],内容: "拼接前缀: ${前缀} 和后缀: ${后缀}"
|
153
|
-
|
153
|
+
|
154
154
|
# 保存到变量中
|
155
155
|
结果变量 = "${前缀}${后缀}"
|
156
156
|
[打印],内容: "拼接结果: ${结果变量}"
|
157
|
-
|
157
|
+
|
158
158
|
# 返回结果
|
159
159
|
return ${结果变量}
|
160
160
|
end
|
@@ -186,19 +186,19 @@ end
|
|
186
186
|
@author: Felix
|
187
187
|
@date: 2024-06-11
|
188
188
|
|
189
|
-
|
189
|
+
function 拼接字符串 (前缀, 后缀="我是默认值哦") do
|
190
190
|
# 直接使用关键字参数
|
191
191
|
[打印],内容:'拼接前缀: ${前缀} 和后缀: ${后缀}'
|
192
|
-
|
192
|
+
|
193
193
|
# 保存到变量中
|
194
194
|
结果变量 = "${前缀}${后缀}"
|
195
195
|
[打印],内容:'拼接结果: ${结果变量}'
|
196
|
-
|
196
|
+
|
197
197
|
# 返回结果
|
198
198
|
return ${结果变量}
|
199
199
|
end
|
200
200
|
|
201
|
-
|
201
|
+
function 计算长度 (文本) do
|
202
202
|
# 在实际场景中,可能会使用更复杂的逻辑
|
203
203
|
[打印],内容:'计算文本: ${文本} 的长度'
|
204
204
|
长度 = 10 # 为简化示例,这里使用固定值
|
@@ -277,7 +277,7 @@ end
|
|
277
277
|
[断言],条件:'${拼接结果} == "你好, 世界"',消息:'字符串拼接不匹配'
|
278
278
|
[断言],条件:'${文本长度} == 10',消息:'长度不匹配'
|
279
279
|
|
280
|
-
|
280
|
+
teardown do
|
281
281
|
[打印],内容:'自定义关键字测试完成'
|
282
282
|
end
|
283
283
|
```
|
@@ -312,7 +312,7 @@ from pytest_dsl.core.auto_decorator import auto_dsl
|
|
312
312
|
@auto_dsl("./api_tests") # 加载指定目录下所有的.auto或.dsl文件
|
313
313
|
class TestAPI:
|
314
314
|
"""API测试类
|
315
|
-
|
315
|
+
|
316
316
|
该类将自动加载api_tests目录下的所有DSL文件作为测试方法
|
317
317
|
"""
|
318
318
|
pass
|
@@ -412,7 +412,7 @@ def call_microservice(**kwargs):
|
|
412
412
|
method = kwargs.get('method_name')
|
413
413
|
params = kwargs.get('params', {})
|
414
414
|
context = kwargs.get('context')
|
415
|
-
|
415
|
+
|
416
416
|
# 实现微服务调用逻辑
|
417
417
|
result = your_microservice_client.call(service, method, params)
|
418
418
|
return result
|
@@ -429,7 +429,7 @@ def call_microservice(**kwargs):
|
|
429
429
|
│ └── api_tests/ # DSL测试文件目录
|
430
430
|
│ ├── login.dsl
|
431
431
|
│ └── users.dsl
|
432
|
-
├──
|
432
|
+
├── config/ # 变量文件
|
433
433
|
│ ├── dev.yaml # 开发环境配置
|
434
434
|
│ └── prod.yaml # 生产环境配置
|
435
435
|
└── pytest.ini # pytest配置
|
@@ -453,14 +453,265 @@ def call_microservice(**kwargs):
|
|
453
453
|
- **完整测试生命周期**:内置teardown、变量管理和断言机制
|
454
454
|
- **非侵入式设计**:以"旁路模式"扩展现有pytest项目,不影响原有测试代码
|
455
455
|
|
456
|
+
## 远程关键字功能
|
457
|
+
|
458
|
+
pytest-dsl支持远程关键字调用,允许您在不同的机器或服务上执行关键字,实现分布式测试。
|
459
|
+
|
460
|
+
### 启动远程关键字服务
|
461
|
+
|
462
|
+
安装pytest-dsl后,可以使用内置命令启动远程关键字服务:
|
463
|
+
|
464
|
+
```bash
|
465
|
+
# 使用默认配置启动(localhost:8270)
|
466
|
+
pytest-dsl-server
|
467
|
+
|
468
|
+
# 自定义主机和端口
|
469
|
+
pytest-dsl-server --host 0.0.0.0 --port 8888
|
470
|
+
|
471
|
+
# 使用API密钥保护服务
|
472
|
+
pytest-dsl-server --api-key your_secret_key
|
473
|
+
```
|
474
|
+
|
475
|
+
#### 分布式测试环境配置
|
476
|
+
|
477
|
+
在分布式测试环境中,您可以在多台机器上启动远程关键字服务:
|
478
|
+
|
479
|
+
1. **主测试机**:运行测试脚本的机器
|
480
|
+
2. **远程执行机**:运行远程关键字服务的机器
|
481
|
+
|
482
|
+
配置步骤:
|
483
|
+
|
484
|
+
1. 在每台远程执行机上安装pytest-dsl:
|
485
|
+
```bash
|
486
|
+
pip install pytest-dsl
|
487
|
+
```
|
488
|
+
|
489
|
+
2. 在每台远程执行机上启动远程关键字服务:
|
490
|
+
```bash
|
491
|
+
# 确保监听所有网络接口,以便外部可访问
|
492
|
+
pytest-dsl-server --host 0.0.0.0 --port 8270
|
493
|
+
```
|
494
|
+
|
495
|
+
3. 在主测试机上编写测试脚本,使用`@remote`指令连接到远程服务:
|
496
|
+
```python
|
497
|
+
# 连接到多台远程执行机
|
498
|
+
@remote: "http://machine1-ip:8270/" as machine1
|
499
|
+
@remote: "http://machine2-ip:8270/" as machine2
|
500
|
+
|
501
|
+
# 在不同机器上执行关键字
|
502
|
+
machine1|[打印],内容: "在机器1上执行"
|
503
|
+
machine2|[打印],内容: "在机器2上执行"
|
504
|
+
```
|
505
|
+
|
506
|
+
### 远程关键字语法
|
507
|
+
|
508
|
+
#### 方式一:DSL中导入(适合临时使用)
|
509
|
+
|
510
|
+
```python
|
511
|
+
# 导入远程关键字服务器
|
512
|
+
@remote: "http://keyword-server:8270/" as machineone
|
513
|
+
@remote: "http://keyword-server2:8270/" as machinetwo
|
514
|
+
|
515
|
+
# 远程关键字调用
|
516
|
+
machineone|[打印],内容: "这是通过远程服务器执行的关键字"
|
517
|
+
结果 = machineone|[拼接字符串],前缀: "Hello, ",后缀: "Remote World!"
|
518
|
+
```
|
519
|
+
|
520
|
+
#### 方式二:YAML配置自动加载(推荐用于全局配置)
|
521
|
+
|
522
|
+
在`config/vars.yaml`或其他YAML配置文件中添加:
|
523
|
+
|
524
|
+
```yaml
|
525
|
+
# 远程服务器配置
|
526
|
+
remote_servers:
|
527
|
+
main_server:
|
528
|
+
url: "http://localhost:8270/"
|
529
|
+
alias: "main"
|
530
|
+
api_key: "your_api_key_here" # 可选
|
531
|
+
sync_config: # 可选
|
532
|
+
sync_global_vars: true
|
533
|
+
sync_yaml_vars: true
|
534
|
+
|
535
|
+
backup_server:
|
536
|
+
url: "http://backup-host:8270/"
|
537
|
+
alias: "backup"
|
538
|
+
```
|
539
|
+
|
540
|
+
然后在DSL中直接使用:
|
541
|
+
|
542
|
+
```python
|
543
|
+
# 无需@remote导入,直接使用YAML中配置的服务器
|
544
|
+
main|[打印],内容: "使用主服务器"
|
545
|
+
backup|[打印],内容: "使用备用服务器"
|
546
|
+
```
|
547
|
+
|
548
|
+
### 远程关键字测试示例
|
549
|
+
|
550
|
+
```python
|
551
|
+
@name: "远程关键字测试"
|
552
|
+
@description: "测试远程关键字的基本功能"
|
553
|
+
@tags: ["remote", "keywords"]
|
554
|
+
@author: "Felix"
|
555
|
+
@date: 2024-05-21
|
556
|
+
|
557
|
+
# 导入远程关键字服务器
|
558
|
+
@remote: "http://localhost:8270/" as machineone
|
559
|
+
|
560
|
+
# 基本打印测试
|
561
|
+
machineone|[打印],内容: "这是通过远程服务器执行的关键字"
|
562
|
+
```
|
563
|
+
|
564
|
+
## 无缝变量传递功能
|
565
|
+
|
566
|
+
pytest-dsl提供了革命性的无缝变量传递功能,客户端的变量会自动传递到服务端,服务端使用时完全透明,无需任何前缀或特殊语法。
|
567
|
+
|
568
|
+
### 功能特性
|
569
|
+
|
570
|
+
- **🔄 无缝传递**:客户端变量自动传递到远程服务器,服务端使用时无需前缀
|
571
|
+
- **🛡️ 智能过滤**:自动过滤敏感信息(password、secret、key等)
|
572
|
+
- **⚡ 零配置**:无需复杂的同步设置,开箱即用
|
573
|
+
- **🎯 优先级保持**:保持变量访问优先级(本地 > 同步)
|
574
|
+
- **🔒 完全隔离**:不同服务器的变量完全隔离,互不影响
|
575
|
+
|
576
|
+
### 基本使用
|
577
|
+
|
578
|
+
**客户端配置 (vars.yaml)**:
|
579
|
+
```yaml
|
580
|
+
# 全局变量
|
581
|
+
g_base_url: "https://api.example.com"
|
582
|
+
|
583
|
+
# HTTP客户端配置
|
584
|
+
http_clients:
|
585
|
+
default:
|
586
|
+
base_url: "${g_base_url}"
|
587
|
+
timeout: 30
|
588
|
+
|
589
|
+
# 测试数据
|
590
|
+
test_data:
|
591
|
+
username: "testuser"
|
592
|
+
email: "test@example.com"
|
593
|
+
|
594
|
+
# 敏感信息(会被自动过滤)
|
595
|
+
password: "secret123"
|
596
|
+
api_key: "sk-1234567890"
|
597
|
+
```
|
598
|
+
|
599
|
+
**DSL测试脚本**:
|
600
|
+
```python
|
601
|
+
# 导入远程关键字服务器(连接时自动传递变量)
|
602
|
+
@remote: "http://localhost:8270/" as remote_server
|
603
|
+
|
604
|
+
# 远程关键字直接使用客户端变量,无需前缀!
|
605
|
+
remote_server|[HTTP请求], 客户端: "default", 配置: '''
|
606
|
+
request:
|
607
|
+
method: GET
|
608
|
+
url: ${g_base_url}/api/data
|
609
|
+
headers:
|
610
|
+
X-User: ${test_data.username}
|
611
|
+
X-Email: ${test_data.email}
|
612
|
+
'''
|
613
|
+
|
614
|
+
# 全局变量也可以直接使用
|
615
|
+
remote_server|[打印], 内容: "API地址: ${g_base_url}"
|
616
|
+
```
|
617
|
+
|
618
|
+
### 配置选项
|
619
|
+
|
620
|
+
可以通过sync_config参数控制传递行为:
|
621
|
+
|
622
|
+
```python
|
623
|
+
# 自定义传递配置
|
624
|
+
sync_config = {
|
625
|
+
'sync_global_vars': True, # 是否传递全局变量
|
626
|
+
'sync_yaml_vars': True, # 是否传递YAML配置变量
|
627
|
+
}
|
628
|
+
|
629
|
+
# 使用自定义配置连接
|
630
|
+
client = RemoteKeywordClient(sync_config=sync_config)
|
631
|
+
```
|
632
|
+
|
633
|
+
### 应用场景
|
634
|
+
|
635
|
+
1. **🌐 跨环境测试**:客户端配置自动传递到不同环境的远程服务器
|
636
|
+
2. **🔧 配置统一管理**:HTTP客户端、数据库连接等配置在客户端统一管理
|
637
|
+
3. **🏢 企业级部署**:测试配置集中管理,远程执行节点自动获取
|
638
|
+
4. **🔒 安全隔离**:敏感信息自动过滤,确保安全性
|
639
|
+
5. **⚡ 性能优化**:计算密集型任务在远程高性能服务器执行,配置无缝传递
|
640
|
+
|
641
|
+
# 随机数生成测试
|
642
|
+
随机数 = [生成随机数],最小值: 1,最大值: 100
|
643
|
+
machineone|[打印],内容: "远程生成的随机数: ${随机数}"
|
644
|
+
```
|
645
|
+
|
646
|
+
### 远程关键字功能特性
|
647
|
+
|
648
|
+
远程关键字功能已经完全支持所有内置关键字,包括:
|
649
|
+
|
650
|
+
- ✅ **HTTP请求关键字**:完整支持变量捕获、会话管理和响应保存
|
651
|
+
- ✅ **断言关键字**:支持各种断言操作
|
652
|
+
- ✅ **全局变量管理**:远程和本地环境独立的全局变量空间
|
653
|
+
- ✅ **JSON操作**:JSON提取和断言功能
|
654
|
+
- ✅ **工具关键字**:随机数生成、字符串操作等
|
655
|
+
- ✅ **时间关键字**:时间获取和格式化
|
656
|
+
|
657
|
+
详细的使用指南和开发文档请参考:
|
658
|
+
- 📖 [远程关键字使用指南](./docs/remote-keywords-usage.md)
|
659
|
+
- 🛠️ [远程关键字开发指南](./docs/remote-keywords-development.md)
|
660
|
+
|
661
|
+
### 远程关键字服务安全性
|
662
|
+
|
663
|
+
在生产环境中使用远程关键字服务时,请注意以下安全建议:
|
664
|
+
|
665
|
+
1. **使用API密钥认证**:
|
666
|
+
```bash
|
667
|
+
pytest-dsl-server --api-key your_secure_key
|
668
|
+
```
|
669
|
+
然后在测试脚本中使用API密钥连接:
|
670
|
+
```python
|
671
|
+
@remote: "http://server:8270/?api_key=your_secure_key" as secure_server
|
672
|
+
```
|
673
|
+
|
674
|
+
2. **限制网络访问**:
|
675
|
+
- 在内部网络或VPN中使用远程关键字服务
|
676
|
+
- 使用防火墙限制对服务端口的访问
|
677
|
+
- 考虑使用SSH隧道连接到远程服务
|
678
|
+
|
679
|
+
3. **监控服务**:
|
680
|
+
- 定期检查服务日志
|
681
|
+
- 监控异常访问模式
|
682
|
+
- 在不需要时关闭服务
|
683
|
+
|
684
|
+
### 远程关键字最佳实践
|
685
|
+
|
686
|
+
1. **合理分配关键字**:
|
687
|
+
- 将计算密集型关键字放在性能更好的机器上
|
688
|
+
- 将特定环境依赖的关键字放在对应环境的机器上
|
689
|
+
|
690
|
+
2. **错误处理**:
|
691
|
+
- 添加适当的错误处理机制,处理远程服务不可用的情况
|
692
|
+
- 使用超时设置避免长时间等待
|
693
|
+
|
694
|
+
3. **变量传递**:
|
695
|
+
- 注意远程关键字执行后,变量会返回到本地上下文
|
696
|
+
- 大型数据应考虑使用文件或数据库共享,而不是直接通过变量传递
|
697
|
+
|
456
698
|
## 进阶文档
|
457
699
|
|
700
|
+
### 核心功能文档
|
458
701
|
- [完整DSL语法指南](./docs/自动化关键字DSL语法设计.md)
|
459
|
-
- [创建自定义关键字](./pytest_dsl/docs/custom_keywords.md)
|
702
|
+
- [创建自定义关键字](./pytest_dsl/docs/custom_keywords.md)
|
460
703
|
- [HTTP测试关键字](./docs/api.md)
|
461
704
|
- [断言关键字详解](./docs/assertion_keywords.md)
|
462
705
|
- [HTTP断言重试机制](./docs/http_assertion_retry.md)
|
463
706
|
|
707
|
+
### 远程关键字文档
|
708
|
+
- 📖 [远程关键字使用指南](./docs/remote-keywords-usage.md) - 如何使用远程关键字功能
|
709
|
+
- 🛠️ [远程关键字开发指南](./docs/remote-keywords-development.md) - 如何开发支持远程模式的关键字
|
710
|
+
- 🔧 [远程服务器Hook机制指南](./docs/remote-hooks-guide.md) - 如何使用hook机制扩展远程服务器功能和实现自定义授权
|
711
|
+
- ⚙️ [YAML远程服务器配置指南](./docs/yaml_remote_servers.md) - 如何通过YAML配置自动加载远程服务器
|
712
|
+
- 🔄 [YAML变量无缝传递功能](./docs/yaml_vars_seamless_sync.md) - 如何实现客户端YAML变量的无缝传递
|
713
|
+
- [远程关键字语法示例](./docs/remote_syntax_example.md) - 基础语法示例
|
714
|
+
|
464
715
|
## 贡献与支持
|
465
716
|
|
466
717
|
我们欢迎您的贡献和反馈!如有问题,请提交issue或PR。
|
@@ -471,4 +722,4 @@ MIT License
|
|
471
722
|
|
472
723
|
---
|
473
724
|
|
474
|
-
开始使用pytest-dsl,释放测试自动化的无限可能!
|
725
|
+
开始使用pytest-dsl,释放测试自动化的无限可能!
|