pytest-dsl 0.3.0__tar.gz → 0.3.1__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.3.0/pytest_dsl.egg-info → pytest_dsl-0.3.1}/PKG-INFO +1 -1
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pyproject.toml +1 -1
- pytest_dsl-0.3.1/pytest_dsl/cli.py +143 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1/pytest_dsl.egg-info}/PKG-INFO +1 -1
- pytest_dsl-0.3.0/pytest_dsl/cli.py +0 -80
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/LICENSE +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/MANIFEST.in +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/README.md +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/__init__.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/conftest_adapter.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/__init__.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/auth_provider.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/auto_decorator.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/auto_directory.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/context.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/custom_keyword_manager.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/dsl_executor.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/dsl_executor_utils.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/global_context.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/http_client.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/http_request.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/keyword_manager.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/lexer.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/parser.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/parsetab.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/plugin_discovery.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/utils.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/variable_utils.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/yaml_loader.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/yaml_vars.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/docs/custom_keywords.md +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/__init__.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/assert/assertion_example.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/assert/boolean_test.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/assert/expression_test.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/custom/test_advanced_keywords.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/custom/test_custom_keywords.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/custom/test_default_values.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/__init__.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/builtin_auth_test.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/file_reference_test.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_advanced.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_example.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_length_test.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_retry_assertions.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_retry_assertions_enhanced.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_with_yaml.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/new_retry_test.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/retry_assertions_only.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/retry_config_only.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/retry_debug.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/retry_with_fix.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/simple_retry.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/vars.yaml +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/quickstart/api_basics.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/quickstart/assertions.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/quickstart/loops.auto +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/test_assert.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/test_custom_keyword.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/test_http.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/test_quickstart.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/__init__.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/assertion_keywords.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/global_keywords.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/http_keywords.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/system_keywords.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/main_adapter.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/parsetab.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/plugin.py +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/SOURCES.txt +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/dependency_links.txt +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/entry_points.txt +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/requires.txt +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/top_level.txt +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/setup.cfg +0 -0
- {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/setup.py +0 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
"""
|
2
|
+
pytest-dsl命令行入口
|
3
|
+
|
4
|
+
提供独立的命令行工具,用于执行DSL文件。
|
5
|
+
"""
|
6
|
+
|
7
|
+
import sys
|
8
|
+
import argparse
|
9
|
+
import pytest
|
10
|
+
import os
|
11
|
+
from pathlib import Path
|
12
|
+
|
13
|
+
from pytest_dsl.core.lexer import get_lexer
|
14
|
+
from pytest_dsl.core.parser import get_parser
|
15
|
+
from pytest_dsl.core.dsl_executor import DSLExecutor
|
16
|
+
from pytest_dsl.core.yaml_vars import yaml_vars
|
17
|
+
from pytest_dsl.core.auto_directory import SETUP_FILE_NAME, TEARDOWN_FILE_NAME, execute_hook_file
|
18
|
+
|
19
|
+
|
20
|
+
def read_file(filename):
|
21
|
+
"""读取 DSL 文件内容"""
|
22
|
+
with open(filename, 'r', encoding='utf-8') as f:
|
23
|
+
return f.read()
|
24
|
+
|
25
|
+
|
26
|
+
def parse_args():
|
27
|
+
"""解析命令行参数"""
|
28
|
+
parser = argparse.ArgumentParser(description='执行DSL测试文件')
|
29
|
+
parser.add_argument('path', help='要执行的DSL文件路径或包含DSL文件的目录')
|
30
|
+
parser.add_argument('--yaml-vars', action='append', default=[],
|
31
|
+
help='YAML变量文件路径,可以指定多个文件 (例如: --yaml-vars vars1.yaml --yaml-vars vars2.yaml)')
|
32
|
+
parser.add_argument('--yaml-vars-dir', default=None,
|
33
|
+
help='YAML变量文件目录路径,将加载该目录下所有.yaml文件')
|
34
|
+
|
35
|
+
return parser.parse_args()
|
36
|
+
|
37
|
+
|
38
|
+
def load_yaml_variables(args):
|
39
|
+
"""从命令行参数加载YAML变量"""
|
40
|
+
# 加载单个YAML文件
|
41
|
+
if args.yaml_vars:
|
42
|
+
yaml_vars.load_yaml_files(args.yaml_vars)
|
43
|
+
print(f"已加载YAML变量文件: {', '.join(args.yaml_vars)}")
|
44
|
+
|
45
|
+
# 加载目录中的YAML文件
|
46
|
+
if args.yaml_vars_dir:
|
47
|
+
yaml_vars_dir = args.yaml_vars_dir
|
48
|
+
try:
|
49
|
+
yaml_vars.load_from_directory(yaml_vars_dir)
|
50
|
+
print(f"已加载YAML变量目录: {yaml_vars_dir}")
|
51
|
+
loaded_files = yaml_vars.get_loaded_files()
|
52
|
+
if loaded_files:
|
53
|
+
dir_files = [f for f in loaded_files if Path(f).parent == Path(yaml_vars_dir)]
|
54
|
+
if dir_files:
|
55
|
+
print(f"目录中加载的文件: {', '.join(dir_files)}")
|
56
|
+
except NotADirectoryError:
|
57
|
+
print(f"YAML变量目录不存在: {yaml_vars_dir}")
|
58
|
+
sys.exit(1)
|
59
|
+
|
60
|
+
|
61
|
+
def execute_dsl_file(file_path, lexer, parser, executor):
|
62
|
+
"""执行单个DSL文件"""
|
63
|
+
try:
|
64
|
+
print(f"执行文件: {file_path}")
|
65
|
+
dsl_code = read_file(file_path)
|
66
|
+
ast = parser.parse(dsl_code, lexer=lexer)
|
67
|
+
executor.execute(ast)
|
68
|
+
return True
|
69
|
+
except Exception as e:
|
70
|
+
print(f"执行失败 {file_path}: {e}")
|
71
|
+
return False
|
72
|
+
|
73
|
+
|
74
|
+
def find_dsl_files(directory):
|
75
|
+
"""查找目录中的所有DSL文件"""
|
76
|
+
dsl_files = []
|
77
|
+
for root, _, files in os.walk(directory):
|
78
|
+
for file in files:
|
79
|
+
if file.endswith(('.dsl', '.auto')) and file not in [SETUP_FILE_NAME, TEARDOWN_FILE_NAME]:
|
80
|
+
dsl_files.append(os.path.join(root, file))
|
81
|
+
return dsl_files
|
82
|
+
|
83
|
+
|
84
|
+
def main():
|
85
|
+
"""命令行入口点"""
|
86
|
+
args = parse_args()
|
87
|
+
path = args.path
|
88
|
+
|
89
|
+
# 加载YAML变量
|
90
|
+
load_yaml_variables(args)
|
91
|
+
|
92
|
+
lexer = get_lexer()
|
93
|
+
parser = get_parser()
|
94
|
+
executor = DSLExecutor()
|
95
|
+
|
96
|
+
# 检查路径是文件还是目录
|
97
|
+
if os.path.isfile(path):
|
98
|
+
# 执行单个文件
|
99
|
+
success = execute_dsl_file(path, lexer, parser, executor)
|
100
|
+
if not success:
|
101
|
+
sys.exit(1)
|
102
|
+
elif os.path.isdir(path):
|
103
|
+
# 执行目录中的所有DSL文件
|
104
|
+
print(f"执行目录: {path}")
|
105
|
+
|
106
|
+
# 先执行目录的setup文件(如果存在)
|
107
|
+
setup_file = os.path.join(path, SETUP_FILE_NAME)
|
108
|
+
if os.path.exists(setup_file):
|
109
|
+
execute_hook_file(Path(setup_file), True, path)
|
110
|
+
|
111
|
+
# 查找并执行所有DSL文件
|
112
|
+
dsl_files = find_dsl_files(path)
|
113
|
+
if not dsl_files:
|
114
|
+
print(f"目录中没有找到DSL文件: {path}")
|
115
|
+
sys.exit(1)
|
116
|
+
|
117
|
+
print(f"找到 {len(dsl_files)} 个DSL文件")
|
118
|
+
|
119
|
+
# 执行所有DSL文件
|
120
|
+
failures = 0
|
121
|
+
for file_path in dsl_files:
|
122
|
+
success = execute_dsl_file(file_path, lexer, parser, executor)
|
123
|
+
if not success:
|
124
|
+
failures += 1
|
125
|
+
|
126
|
+
# 最后执行目录的teardown文件(如果存在)
|
127
|
+
teardown_file = os.path.join(path, TEARDOWN_FILE_NAME)
|
128
|
+
if os.path.exists(teardown_file):
|
129
|
+
execute_hook_file(Path(teardown_file), False, path)
|
130
|
+
|
131
|
+
# 如果有失败的测试,返回非零退出码
|
132
|
+
if failures > 0:
|
133
|
+
print(f"总计 {failures}/{len(dsl_files)} 个测试失败")
|
134
|
+
sys.exit(1)
|
135
|
+
else:
|
136
|
+
print(f"所有 {len(dsl_files)} 个测试成功完成")
|
137
|
+
else:
|
138
|
+
print(f"路径不存在: {path}")
|
139
|
+
sys.exit(1)
|
140
|
+
|
141
|
+
|
142
|
+
if __name__ == '__main__':
|
143
|
+
main()
|
@@ -1,80 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
pytest-dsl命令行入口
|
3
|
-
|
4
|
-
提供独立的命令行工具,用于执行DSL文件。
|
5
|
-
"""
|
6
|
-
|
7
|
-
import sys
|
8
|
-
import argparse
|
9
|
-
import pytest
|
10
|
-
from pathlib import Path
|
11
|
-
|
12
|
-
from pytest_dsl.core.lexer import get_lexer
|
13
|
-
from pytest_dsl.core.parser import get_parser
|
14
|
-
from pytest_dsl.core.dsl_executor import DSLExecutor
|
15
|
-
from pytest_dsl.core.yaml_vars import yaml_vars
|
16
|
-
|
17
|
-
|
18
|
-
def read_file(filename):
|
19
|
-
"""读取 DSL 文件内容"""
|
20
|
-
with open(filename, 'r', encoding='utf-8') as f:
|
21
|
-
return f.read()
|
22
|
-
|
23
|
-
|
24
|
-
def parse_args():
|
25
|
-
"""解析命令行参数"""
|
26
|
-
parser = argparse.ArgumentParser(description='执行DSL测试文件')
|
27
|
-
parser.add_argument('dsl_file', help='要执行的DSL文件路径')
|
28
|
-
parser.add_argument('--yaml-vars', action='append', default=[],
|
29
|
-
help='YAML变量文件路径,可以指定多个文件 (例如: --yaml-vars vars1.yaml --yaml-vars vars2.yaml)')
|
30
|
-
parser.add_argument('--yaml-vars-dir', default=None,
|
31
|
-
help='YAML变量文件目录路径,将加载该目录下所有.yaml文件')
|
32
|
-
|
33
|
-
return parser.parse_args()
|
34
|
-
|
35
|
-
|
36
|
-
def load_yaml_variables(args):
|
37
|
-
"""从命令行参数加载YAML变量"""
|
38
|
-
# 加载单个YAML文件
|
39
|
-
if args.yaml_vars:
|
40
|
-
yaml_vars.load_yaml_files(args.yaml_vars)
|
41
|
-
print(f"已加载YAML变量文件: {', '.join(args.yaml_vars)}")
|
42
|
-
|
43
|
-
# 加载目录中的YAML文件
|
44
|
-
if args.yaml_vars_dir:
|
45
|
-
yaml_vars_dir = args.yaml_vars_dir
|
46
|
-
try:
|
47
|
-
yaml_vars.load_from_directory(yaml_vars_dir)
|
48
|
-
print(f"已加载YAML变量目录: {yaml_vars_dir}")
|
49
|
-
loaded_files = yaml_vars.get_loaded_files()
|
50
|
-
if loaded_files:
|
51
|
-
dir_files = [f for f in loaded_files if Path(f).parent == Path(yaml_vars_dir)]
|
52
|
-
if dir_files:
|
53
|
-
print(f"目录中加载的文件: {', '.join(dir_files)}")
|
54
|
-
except NotADirectoryError:
|
55
|
-
print(f"YAML变量目录不存在: {yaml_vars_dir}")
|
56
|
-
sys.exit(1)
|
57
|
-
|
58
|
-
|
59
|
-
def main():
|
60
|
-
"""命令行入口点"""
|
61
|
-
args = parse_args()
|
62
|
-
|
63
|
-
# 加载YAML变量
|
64
|
-
load_yaml_variables(args)
|
65
|
-
|
66
|
-
lexer = get_lexer()
|
67
|
-
parser = get_parser()
|
68
|
-
executor = DSLExecutor()
|
69
|
-
|
70
|
-
try:
|
71
|
-
dsl_code = read_file(args.dsl_file)
|
72
|
-
ast = parser.parse(dsl_code, lexer=lexer)
|
73
|
-
executor.execute(ast)
|
74
|
-
except Exception as e:
|
75
|
-
print(f"执行失败: {e}")
|
76
|
-
sys.exit(1)
|
77
|
-
|
78
|
-
|
79
|
-
if __name__ == '__main__':
|
80
|
-
main()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/custom/test_advanced_keywords.auto
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_retry_assertions_enhanced.auto
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|