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.
Files changed (76) hide show
  1. {pytest_dsl-0.3.0/pytest_dsl.egg-info → pytest_dsl-0.3.1}/PKG-INFO +1 -1
  2. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pyproject.toml +1 -1
  3. pytest_dsl-0.3.1/pytest_dsl/cli.py +143 -0
  4. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1/pytest_dsl.egg-info}/PKG-INFO +1 -1
  5. pytest_dsl-0.3.0/pytest_dsl/cli.py +0 -80
  6. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/LICENSE +0 -0
  7. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/MANIFEST.in +0 -0
  8. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/README.md +0 -0
  9. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/__init__.py +0 -0
  10. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/conftest_adapter.py +0 -0
  11. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/__init__.py +0 -0
  12. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/auth_provider.py +0 -0
  13. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/auto_decorator.py +0 -0
  14. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/auto_directory.py +0 -0
  15. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/context.py +0 -0
  16. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/custom_keyword_manager.py +0 -0
  17. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/dsl_executor.py +0 -0
  18. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/dsl_executor_utils.py +0 -0
  19. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/global_context.py +0 -0
  20. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/http_client.py +0 -0
  21. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/http_request.py +0 -0
  22. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/keyword_manager.py +0 -0
  23. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/lexer.py +0 -0
  24. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/parser.py +0 -0
  25. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/parsetab.py +0 -0
  26. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/plugin_discovery.py +0 -0
  27. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/utils.py +0 -0
  28. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/variable_utils.py +0 -0
  29. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/yaml_loader.py +0 -0
  30. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/core/yaml_vars.py +0 -0
  31. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/docs/custom_keywords.md +0 -0
  32. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/__init__.py +0 -0
  33. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/assert/assertion_example.auto +0 -0
  34. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/assert/boolean_test.auto +0 -0
  35. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/assert/expression_test.auto +0 -0
  36. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/custom/test_advanced_keywords.auto +0 -0
  37. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/custom/test_custom_keywords.auto +0 -0
  38. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/custom/test_default_values.auto +0 -0
  39. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/__init__.py +0 -0
  40. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/builtin_auth_test.auto +0 -0
  41. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/file_reference_test.auto +0 -0
  42. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_advanced.auto +0 -0
  43. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_example.auto +0 -0
  44. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_length_test.auto +0 -0
  45. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_retry_assertions.auto +0 -0
  46. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_retry_assertions_enhanced.auto +0 -0
  47. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/http_with_yaml.auto +0 -0
  48. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/new_retry_test.auto +0 -0
  49. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/retry_assertions_only.auto +0 -0
  50. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/retry_config_only.auto +0 -0
  51. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/retry_debug.auto +0 -0
  52. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/retry_with_fix.auto +0 -0
  53. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/simple_retry.auto +0 -0
  54. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/http/vars.yaml +0 -0
  55. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/quickstart/api_basics.auto +0 -0
  56. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/quickstart/assertions.auto +0 -0
  57. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/quickstart/loops.auto +0 -0
  58. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/test_assert.py +0 -0
  59. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/test_custom_keyword.py +0 -0
  60. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/test_http.py +0 -0
  61. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/examples/test_quickstart.py +0 -0
  62. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/__init__.py +0 -0
  63. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/assertion_keywords.py +0 -0
  64. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/global_keywords.py +0 -0
  65. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/http_keywords.py +0 -0
  66. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/keywords/system_keywords.py +0 -0
  67. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/main_adapter.py +0 -0
  68. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/parsetab.py +0 -0
  69. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl/plugin.py +0 -0
  70. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/SOURCES.txt +0 -0
  71. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/dependency_links.txt +0 -0
  72. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/entry_points.txt +0 -0
  73. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/requires.txt +0 -0
  74. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/pytest_dsl.egg-info/top_level.txt +0 -0
  75. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/setup.cfg +0 -0
  76. {pytest_dsl-0.3.0 → pytest_dsl-0.3.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-dsl
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A DSL testing framework based on pytest
5
5
  Author: Chen Shuanglin
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pytest-dsl"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "A DSL testing framework based on pytest"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-dsl
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A DSL testing framework based on pytest
5
5
  Author: Chen Shuanglin
6
6
  License: MIT
@@ -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