cli-test-framework 0.3.0__tar.gz → 0.3.2__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 (61) hide show
  1. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/CHANGELOG.md +25 -0
  2. cli_test_framework-0.3.2/PKG-INFO +546 -0
  3. cli_test_framework-0.3.0/src/cli_test_framework.egg-info/PKG-INFO → cli_test_framework-0.3.2/README.md +66 -38
  4. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/setup.py +3 -3
  5. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/__init__.py +1 -1
  6. cli_test_framework-0.3.2/src/cli_test_framework.egg-info/PKG-INFO +546 -0
  7. cli_test_framework-0.3.0/PKG-INFO +0 -445
  8. cli_test_framework-0.3.0/README.md +0 -410
  9. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/MANIFEST.in +0 -0
  10. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/docs/user_manual.md +0 -0
  11. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/pyproject.toml +0 -0
  12. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/setup.cfg +0 -0
  13. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/cli.py +0 -0
  14. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/commands/__init__.py +0 -0
  15. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/commands/compare.py +0 -0
  16. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/core/__init__.py +0 -0
  17. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/core/assertions.py +0 -0
  18. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/core/base_runner.py +0 -0
  19. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/core/parallel_runner.py +0 -0
  20. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/core/process_worker.py +0 -0
  21. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/core/setup.py +0 -0
  22. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/core/test_case.py +0 -0
  23. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/__init__.py +0 -0
  24. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/base_comparator.py +0 -0
  25. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/binary_comparator.py +0 -0
  26. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/csv_comparator.py +0 -0
  27. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/factory.py +0 -0
  28. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/h5_comparator.py +0 -0
  29. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/json_comparator.py +0 -0
  30. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/result.py +0 -0
  31. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/text_comparator.py +0 -0
  32. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/file_comparator/xml_comparator.py +0 -0
  33. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/runners/__init__.py +0 -0
  34. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/runners/json_runner.py +0 -0
  35. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/runners/parallel_json_runner.py +0 -0
  36. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/runners/yaml_runner.py +0 -0
  37. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/utils/__init__.py +0 -0
  38. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/utils/path_resolver.py +0 -0
  39. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework/utils/report_generator.py +0 -0
  40. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework.egg-info/SOURCES.txt +0 -0
  41. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework.egg-info/dependency_links.txt +0 -0
  42. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework.egg-info/entry_points.txt +0 -0
  43. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework.egg-info/requires.txt +0 -0
  44. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/src/cli_test_framework.egg-info/top_level.txt +0 -0
  45. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/__init__.py +0 -0
  46. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/__pycache__/__init__.cpython-312.pyc +0 -0
  47. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/__pycache__/test_parallel_runner.cpython-312-pytest-7.4.4.pyc +0 -0
  48. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/__pycache__/test_setup_module.cpython-312-pytest-7.4.4.pyc +0 -0
  49. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/fixtures/test_cases.json +0 -0
  50. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/fixtures/test_cases.yaml +0 -0
  51. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/fixtures/test_cases1.json +0 -0
  52. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/fixtures/test_with_setup.json +0 -0
  53. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/fixtures/test_with_setup.yaml +0 -0
  54. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/performance_test.py +0 -0
  55. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/test1.py +0 -0
  56. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/test_comprehensive_space.py +0 -0
  57. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/test_parallel_runner.py +0 -0
  58. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/test_parallel_space.py +0 -0
  59. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/test_report.txt +0 -0
  60. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/test_runners.py +0 -0
  61. {cli_test_framework-0.3.0 → cli_test_framework-0.3.2}/tests/test_setup_module.py +0 -0
@@ -1,5 +1,30 @@
1
1
  # 变更日志
2
2
 
3
+ ## [v0.3.2] - 2024-12-29
4
+
5
+ ### 🔧 重大改进
6
+ - **PyPI文档更新**:PyPI项目页面现在显示完整的用户手册内容(包含Setup模块文档)
7
+ - **README重构**:更新README.md添加Setup模块使用示例和配置说明
8
+ - **文档源切换**:setup.py现在使用`docs/user_manual.md`作为PyPI项目描述
9
+
10
+ ### 📚 文档增强
11
+ - 在README中添加了Setup模块的快速使用示例
12
+ - 添加了带环境变量配置的JSON/YAML示例
13
+ - 增加了指向完整用户手册的链接和说明
14
+ - 改善了文档结构和可读性
15
+
16
+ ## [v0.3.1] - 2024-12-29
17
+
18
+ ### 🔧 改进
19
+ - **文档更新**:完善了用户手册中的Setup模块文档
20
+ - **示例增强**:增加了更多详细的配置示例和最佳实践说明
21
+ - **PyPI发布**:确保最新的用户手册包含在PyPI包中
22
+
23
+ ### 📚 文档修复
24
+ - 修复了用户手册格式问题
25
+ - 改进了Setup模块的使用示例
26
+ - 补充了更多自定义插件开发指南
27
+
3
28
  ## [v0.3.0] - 2025-06-07
4
29
 
5
30
  ### 🎉 重大新功能 - Setup模块系统
@@ -0,0 +1,546 @@
1
+ Metadata-Version: 2.4
2
+ Name: cli-test-framework
3
+ Version: 0.3.2
4
+ Summary: A powerful command line testing framework in Python with setup modules, parallel execution, and file comparison capabilities.
5
+ Home-page: https://github.com/yourusername/cli-test-framework
6
+ Author: Xiaotong Wang
7
+ Author-email: xiaotongwang98@gmail.com
8
+ Project-URL: Documentation, https://github.com/yourusername/cli-test-framework/docs/user_manual.md
9
+ Project-URL: Source, https://github.com/yourusername/cli-test-framework
10
+ Project-URL: Tracker, https://github.com/yourusername/cli-test-framework/issues
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: dukpy==0.5.0
21
+ Requires-Dist: h5py>=3.8.0
22
+ Requires-Dist: numpy>=2.0.1
23
+ Requires-Dist: setuptools>=75.8.0
24
+ Requires-Dist: wheel>=0.45.1
25
+ Dynamic: author
26
+ Dynamic: author-email
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: home-page
31
+ Dynamic: project-url
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # CLI Testing Framework User Manual
37
+
38
+ ## Table of Contents
39
+ 1. [Introduction](#introduction)
40
+ 2. [Installation](#installation)
41
+ 3. [Basic Usage](#basic-usage)
42
+ 4. [Test Case Definition](#test-case-definition)
43
+ 5. [Setup Module](#setup-module)
44
+ 6. [Parallel Testing](#parallel-testing)
45
+ 7. [File Comparison](#file-comparison)
46
+ 8. [Advanced Features](#advanced-features)
47
+ 9. [Troubleshooting](#troubleshooting)
48
+ 10. [API Reference](#api-reference)
49
+ 11. [Examples](#examples)
50
+
51
+ ## Introduction
52
+
53
+ The CLI Testing Framework is a powerful tool designed for testing command-line applications and scripts. It provides a structured way to define, execute, and verify test cases, with support for parallel execution and advanced file comparison capabilities.
54
+
55
+ ### Key Features
56
+ - Parallel test execution with thread and process support
57
+ - JSON/YAML test case definition
58
+ - Advanced file comparison capabilities
59
+ - Comprehensive reporting
60
+ - Extensible architecture
61
+
62
+ ## Installation
63
+
64
+ ### Prerequisites
65
+ - Python 3.6 or higher
66
+ - pip package manager
67
+
68
+ ### Basic Installation
69
+ ```bash
70
+ pip install cli-test-framework
71
+ ```
72
+
73
+ ### Development Installation
74
+ ```bash
75
+ git clone https://github.com/yourusername/cli-test-framework.git
76
+ cd cli-test-framework
77
+ pip install -e .
78
+ ```
79
+
80
+ ## Basic Usage
81
+
82
+ ### Creating a Test Case
83
+
84
+ 1. Create a JSON test case file (e.g., `test_cases.json`):
85
+ ```json
86
+ {
87
+ "test_cases": [
88
+ {
89
+ "name": "Basic Command Test",
90
+ "command": "echo",
91
+ "args": ["Hello, World!"],
92
+ "expected": {
93
+ "return_code": 0,
94
+ "output_contains": ["Hello, World!"]
95
+ }
96
+ }
97
+ ]
98
+ }
99
+ ```
100
+
101
+ 2. Run the test:
102
+ ```python
103
+ from cli_test_framework.runners import JSONRunner
104
+
105
+ runner = JSONRunner(
106
+ config_file="test_cases.json",
107
+ workspace="/path/to/workspace"
108
+ )
109
+ success = runner.run_tests()
110
+ ```
111
+
112
+ ### Using the Command Line
113
+
114
+ ```bash
115
+ # Run tests from a JSON file
116
+ cli-test run test_cases.json
117
+
118
+ # Run tests in parallel
119
+ cli-test run test_cases.json --parallel --workers 4
120
+ ```
121
+
122
+ ## Test Case Definition
123
+
124
+ ### JSON Format
125
+
126
+ ```json
127
+ {
128
+ "test_cases": [
129
+ {
130
+ "name": "Test Case Name",
131
+ "command": "command_to_execute",
132
+ "args": ["arg1", "arg2"],
133
+ "expected": {
134
+ "return_code": 0,
135
+ "output_contains": ["expected text"],
136
+ "output_matches": [".*regex pattern.*"]
137
+ }
138
+ }
139
+ ]
140
+ }
141
+ ```
142
+
143
+ ### YAML Format
144
+
145
+ ```yaml
146
+ test_cases:
147
+ - name: Test Case Name
148
+ command: command_to_execute
149
+ args:
150
+ - arg1
151
+ - arg2
152
+ expected:
153
+ return_code: 0
154
+ output_contains:
155
+ - expected text
156
+ output_matches:
157
+ - ".*regex pattern.*"
158
+ ```
159
+
160
+ ## Setup Module
161
+
162
+ The Setup Module provides a plugin-based system for executing pre-test setup tasks and post-test cleanup. It's designed to be extensible and supports multiple setup plugins running in sequence.
163
+
164
+ ### Key Features
165
+ - **Plugin Architecture**: Extensible design allowing custom setup plugins
166
+ - **Built-in Environment Plugin**: Set environment variables for tests
167
+ - **Full Runner Support**: Works with JSONRunner, YAMLRunner, and ParallelJSONRunner
168
+ - **Lifecycle Management**: Automatic setup and teardown with proper cleanup
169
+
170
+ ### Environment Variable Setup
171
+
172
+ #### JSON Configuration
173
+ ```json
174
+ {
175
+ "setup": {
176
+ "environment_variables": {
177
+ "TEST_ENV": "development",
178
+ "DEBUG_MODE": "true",
179
+ "API_URL": "http://localhost:8080",
180
+ "DATABASE_URL": "sqlite:///test.db"
181
+ }
182
+ },
183
+ "test_cases": [
184
+ {
185
+ "name": "Test with environment variables",
186
+ "command": "python",
187
+ "args": ["-c", "import os; print(f'Env: {os.environ.get(\"TEST_ENV\")}')"],
188
+ "expected": {
189
+ "return_code": 0,
190
+ "output_contains": ["Env: development"]
191
+ }
192
+ }
193
+ ]
194
+ }
195
+ ```
196
+
197
+ #### YAML Configuration
198
+ ```yaml
199
+ setup:
200
+ environment_variables:
201
+ TEST_ENV: "production"
202
+ DATABASE_URL: "postgresql://localhost:5432/test"
203
+ MAX_CONNECTIONS: "10"
204
+ TIMEOUT_SECONDS: "30"
205
+
206
+ test_cases:
207
+ - name: "Test database environment"
208
+ command: "python"
209
+ args:
210
+ - "-c"
211
+ - "import os; print(f'DB: {os.environ.get(\"DATABASE_URL\")}')"
212
+ expected:
213
+ return_code: 0
214
+ output_contains:
215
+ - "DB: postgresql://localhost:5432/test"
216
+ ```
217
+
218
+ ### Custom Setup Plugins
219
+
220
+ #### Creating Custom Plugins
221
+ ```python
222
+ from cli_test_framework import BaseSetup
223
+
224
+ class DatabaseSetup(BaseSetup):
225
+ def setup(self):
226
+ """Initialize test database"""
227
+ print("Setting up test database...")
228
+ # Your database initialization code here
229
+
230
+ def teardown(self):
231
+ """Clean up test database"""
232
+ print("Cleaning up test database...")
233
+ # Your database cleanup code here
234
+
235
+ class ServiceSetup(BaseSetup):
236
+ def setup(self):
237
+ """Start test services"""
238
+ self.service_port = self.config.get('port', 8080)
239
+ print(f"Starting test service on port {self.service_port}")
240
+ # Your service startup code here
241
+
242
+ def teardown(self):
243
+ """Stop test services"""
244
+ print("Stopping test services...")
245
+ # Your service shutdown code here
246
+ ```
247
+
248
+ #### Using Custom Plugins
249
+ ```python
250
+ from cli_test_framework import JSONRunner
251
+
252
+ # Create runner
253
+ runner = JSONRunner("test_cases.json")
254
+
255
+ # Add custom setup plugins
256
+ db_setup = DatabaseSetup({"connection": "test_db"})
257
+ service_setup = ServiceSetup({"port": 9090})
258
+
259
+ runner.setup_manager.add_setup(db_setup)
260
+ runner.setup_manager.add_setup(service_setup)
261
+
262
+ # Run tests (setup will be executed automatically)
263
+ success = runner.run_tests()
264
+ ```
265
+
266
+ ### Execution Flow
267
+
268
+ 1. **Load Configuration**: Read setup configuration from test file
269
+ 2. **Setup Phase**: Execute all setup plugins in order
270
+ - Environment variables are set
271
+ - Custom setups are executed
272
+ - Setup status is reported
273
+ 3. **Test Execution**: Run all test cases with setup environment
274
+ 4. **Teardown Phase**: Clean up all setups in reverse order
275
+ - Environment variables are restored
276
+ - Custom cleanups are executed
277
+ - Cleanup is guaranteed even if tests fail
278
+
279
+ ### Best Practices
280
+
281
+ 1. **Idempotent Operations**: Make setup operations safe to run multiple times
282
+ 2. **Proper Cleanup**: Always implement teardown to avoid side effects
283
+ 3. **Error Handling**: Setup failures stop test execution, teardown failures don't
284
+ 4. **Resource Management**: Use try-finally patterns in custom plugins
285
+ 5. **Configuration Validation**: Check required configuration parameters in setup
286
+
287
+ ### Integration Examples
288
+
289
+ #### With JSON Runner
290
+ ```bash
291
+ cli-test test_with_setup.json
292
+ ```
293
+
294
+ #### With YAML Runner
295
+ ```bash
296
+ cli-test test_with_setup.yaml --runner yaml
297
+ ```
298
+
299
+ #### With Parallel Runner
300
+ ```bash
301
+ cli-test test_with_setup.json --runner parallel --max-workers 4
302
+ ```
303
+
304
+ Note: In parallel mode, setup and teardown run in the main thread to ensure environment consistency.
305
+
306
+ ## Parallel Testing
307
+
308
+ ### Thread Mode
309
+ ```python
310
+ from cli_test_framework.runners import ParallelJSONRunner
311
+
312
+ runner = ParallelJSONRunner(
313
+ config_file="test_cases.json",
314
+ max_workers=4,
315
+ execution_mode="thread"
316
+ )
317
+ success = runner.run_tests()
318
+ ```
319
+
320
+ ### Process Mode
321
+ ```python
322
+ runner = ParallelJSONRunner(
323
+ config_file="test_cases.json",
324
+ max_workers=2,
325
+ execution_mode="process"
326
+ )
327
+ success = runner.run_tests()
328
+ ```
329
+
330
+ ## File Comparison
331
+
332
+ ### Basic File Comparison
333
+ ```bash
334
+ # Compare two text files
335
+ compare-files file1.txt file2.txt
336
+
337
+ # Compare with specific options
338
+ compare-files file1.txt file2.txt --start-line 10 --end-line 20
339
+ ```
340
+
341
+ ### JSON File Comparison
342
+ ```bash
343
+ # Exact comparison
344
+ compare-files data1.json data2.json
345
+
346
+ # Key-based comparison
347
+ compare-files data1.json data2.json --json-compare-mode key-based --json-key-field id
348
+ ```
349
+
350
+ ### HDF5 File Comparison
351
+ ```bash
352
+ # Compare specific tables
353
+ compare-files data1.h5 data2.h5 --h5-table table1,table2
354
+
355
+ # Compare with numerical tolerance
356
+ compare-files data1.h5 data2.h5 --h5-rtol 1e-5 --h5-atol 1e-8
357
+ ```
358
+
359
+ ### Binary File Comparison
360
+ ```bash
361
+ # Compare with similarity check
362
+ compare-files binary1.bin binary2.bin --similarity
363
+
364
+ # Compare with custom chunk size
365
+ compare-files binary1.bin binary2.bin --chunk-size 16384
366
+ ```
367
+
368
+ ## Advanced Features
369
+
370
+ ### Custom Assertions
371
+ ```python
372
+ from cli_test_framework.assertions import BaseAssertion
373
+
374
+ class CustomAssertion(BaseAssertion):
375
+ def assert_custom_condition(self, actual, expected):
376
+ if not self._check_custom_condition(actual, expected):
377
+ raise AssertionError("Custom condition not met")
378
+ ```
379
+
380
+ ### Custom Runners
381
+ ```python
382
+ from cli_test_framework.runners import BaseRunner
383
+
384
+ class CustomRunner(BaseRunner):
385
+ def load_test_cases(self):
386
+ # Custom test case loading logic
387
+ pass
388
+
389
+ def run_test(self, test_case):
390
+ # Custom test execution logic
391
+ pass
392
+ ```
393
+
394
+ ### Output Formats
395
+ ```python
396
+ # JSON output
397
+ runner = JSONRunner(config_file="test_cases.json", output_format="json")
398
+
399
+ # HTML output
400
+ runner = JSONRunner(config_file="test_cases.json", output_format="html")
401
+ ```
402
+
403
+ ## Troubleshooting
404
+
405
+ ### Common Issues
406
+
407
+ 1. **Command Not Found**
408
+ - Ensure the command is in the system PATH
409
+ - Use absolute paths for scripts
410
+ - Check command permissions
411
+
412
+ 2. **Parallel Execution Issues**
413
+ - Reduce number of workers
414
+ - Check for resource conflicts
415
+ - Use process mode for CPU-intensive tests
416
+
417
+ 3. **File Comparison Issues**
418
+ - Verify file permissions
419
+ - Check file encoding
420
+ - Ensure sufficient memory for large files
421
+
422
+ ### Debug Mode
423
+ ```python
424
+ runner = JSONRunner(
425
+ config_file="test_cases.json",
426
+ debug=True
427
+ )
428
+ ```
429
+
430
+ ## API Reference
431
+
432
+ ### Core Classes
433
+
434
+ #### JSONRunner
435
+ ```python
436
+ class JSONRunner:
437
+ def __init__(self, config_file, workspace=None, debug=False):
438
+ """
439
+ Initialize JSONRunner
440
+ :param config_file: Path to JSON test case file
441
+ :param workspace: Working directory for test execution
442
+ :param debug: Enable debug mode
443
+ """
444
+ ```
445
+
446
+ #### ParallelJSONRunner
447
+ ```python
448
+ class ParallelJSONRunner:
449
+ def __init__(self, config_file, max_workers=None, execution_mode="thread"):
450
+ """
451
+ Initialize ParallelJSONRunner
452
+ :param config_file: Path to JSON test case file
453
+ :param max_workers: Maximum number of parallel workers
454
+ :param execution_mode: "thread" or "process"
455
+ """
456
+ ```
457
+
458
+ ### File Comparison
459
+
460
+ #### ComparatorFactory
461
+ ```python
462
+ class ComparatorFactory:
463
+ @staticmethod
464
+ def create_comparator(file_type, **kwargs):
465
+ """
466
+ Create a comparator instance
467
+ :param file_type: Type of file to compare
468
+ :param kwargs: Additional comparator options
469
+ :return: Comparator instance
470
+ """
471
+ ```
472
+
473
+ ## Examples
474
+
475
+ ### Complete Test Suite
476
+ ```python
477
+ from cli_test_framework.runners import JSONRunner
478
+ from cli_test_framework.assertions import Assertions
479
+
480
+ # Create test runner
481
+ runner = JSONRunner(
482
+ config_file="test_suite.json",
483
+ workspace="/project/root",
484
+ debug=True
485
+ )
486
+
487
+ # Run tests
488
+ success = runner.run_tests()
489
+
490
+ # Process results
491
+ if success:
492
+ print("All tests passed!")
493
+ else:
494
+ print("Some tests failed:")
495
+ for result in runner.results["details"]:
496
+ if result["status"] == "failed":
497
+ print(f"- {result['name']}: {result['message']}")
498
+ ```
499
+
500
+ ### Parallel Test Suite
501
+ ```python
502
+ from cli_test_framework.runners import ParallelJSONRunner
503
+ import os
504
+
505
+ # Create parallel runner
506
+ runner = ParallelJSONRunner(
507
+ config_file="test_suite.json",
508
+ max_workers=os.cpu_count() * 2,
509
+ execution_mode="thread"
510
+ )
511
+
512
+ # Run tests in parallel
513
+ success = runner.run_tests()
514
+
515
+ # Generate report
516
+ runner.generate_report("test_report.html")
517
+ ```
518
+
519
+ ### File Comparison Suite
520
+ ```python
521
+ from cli_test_framework.file_comparator import ComparatorFactory
522
+
523
+ # Compare text files
524
+ text_comparator = ComparatorFactory.create_comparator(
525
+ "text",
526
+ encoding="utf-8",
527
+ verbose=True
528
+ )
529
+ text_result = text_comparator.compare_files("file1.txt", "file2.txt")
530
+
531
+ # Compare JSON files
532
+ json_comparator = ComparatorFactory.create_comparator(
533
+ "json",
534
+ compare_mode="key-based",
535
+ key_field="id"
536
+ )
537
+ json_result = json_comparator.compare_files("data1.json", "data2.json")
538
+ ```
539
+
540
+ ## Contributing
541
+
542
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
543
+
544
+ ## License
545
+
546
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -1,38 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: cli-test-framework
3
- Version: 0.3.0
4
- Summary: A powerful command line testing framework in Python with setup modules, parallel execution, and file comparison capabilities.
5
- Home-page: https://github.com/yourusername/cli-test-framework
6
- Author: Xiaotong Wang
7
- Author-email: xiaotongwang98@gmail.com
8
- Project-URL: Documentation, https://github.com/yourusername/cli-test-framework/docs/user_manual.md
9
- Project-URL: Source, https://github.com/yourusername/cli-test-framework
10
- Project-URL: Tracker, https://github.com/yourusername/cli-test-framework/issues
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Development Status :: 4 - Beta
15
- Classifier: Intended Audience :: Developers
16
- Classifier: Topic :: Software Development :: Testing
17
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
- Requires-Python: >=3.9
19
- Description-Content-Type: text/markdown
20
- Requires-Dist: dukpy==0.5.0
21
- Requires-Dist: h5py>=3.8.0
22
- Requires-Dist: numpy>=2.0.1
23
- Requires-Dist: setuptools>=75.8.0
24
- Requires-Dist: wheel>=0.45.1
25
- Dynamic: author
26
- Dynamic: author-email
27
- Dynamic: classifier
28
- Dynamic: description
29
- Dynamic: description-content-type
30
- Dynamic: home-page
31
- Dynamic: project-url
32
- Dynamic: requires-dist
33
- Dynamic: requires-python
34
- Dynamic: summary
35
-
36
1
  # CLI Testing Framework
37
2
 
38
3
  ## 1. Overview
@@ -42,7 +7,8 @@ This is a lightweight and extensible automated testing framework that supports d
42
7
  ## 2. Features
43
8
 
44
9
  - **🚀 Parallel Test Execution**: Support for multi-threading and multi-processing parallel testing with significant performance improvements
45
- - **🏗️ Modular Architecture**: Decoupled design of core components (runner/assertion/report)
10
+ - **🔧 Setup Module System**: Plugin-based architecture for pre-test setup tasks (environment variables, database initialization, service startup)
11
+ - **🏗️ Modular Architecture**: Decoupled design of core components (runner/assertion/report/setup)
46
12
  - **📄 Multi-Format Support**: Native support for JSON/YAML test case formats
47
13
  - **🧠 Intelligent Command Parsing**: Smart handling of complex commands like `"python ./script.py"`
48
14
  - **📁 Smart Path Resolution**: Automatic handling of relative and absolute path conversions
@@ -89,6 +55,21 @@ runner = ParallelJSONRunner(
89
55
  success = runner.run_tests()
90
56
  ```
91
57
 
58
+ ### Setup Module Usage
59
+
60
+ ```python
61
+ from cli_test_framework import JSONRunner, EnvironmentSetup
62
+
63
+ # Using built-in environment variable setup
64
+ runner = JSONRunner("test_cases.json")
65
+ env_setup = EnvironmentSetup({
66
+ "TEST_ENV": "development",
67
+ "API_URL": "http://localhost:8080"
68
+ })
69
+ runner.setup_manager.add_setup(env_setup)
70
+ success = runner.run_tests()
71
+ ```
72
+
92
73
  ### File Comparison
93
74
 
94
75
  ```bash
@@ -111,9 +92,25 @@ compare-files binary1.bin binary2.bin --similarity
111
92
 
112
93
  ```json
113
94
  {
95
+ "setup": {
96
+ "environment_variables": {
97
+ "TEST_ENV": "development",
98
+ "API_URL": "http://localhost:8080",
99
+ "DEBUG_MODE": "true"
100
+ }
101
+ },
114
102
  "test_cases": [
115
103
  {
116
- "name": "File Comparison Test",
104
+ "name": "Environment Variable Test",
105
+ "command": "python",
106
+ "args": ["-c", "import os; print(f'Environment: {os.environ.get(\"TEST_ENV\")}')"],
107
+ "expected": {
108
+ "return_code": 0,
109
+ "output_contains": ["Environment: development"]
110
+ }
111
+ },
112
+ {
113
+ "name": "File Comparison Test",
117
114
  "command": "compare-files",
118
115
  "args": ["file1.txt", "file2.txt", "--verbose"],
119
116
  "expected": {
@@ -129,7 +126,22 @@ compare-files binary1.bin binary2.bin --similarity
129
126
  ### YAML Format
130
127
 
131
128
  ```yaml
129
+ setup:
130
+ environment_variables:
131
+ TEST_ENV: "production"
132
+ DATABASE_URL: "sqlite:///test.db"
133
+
132
134
  test_cases:
135
+ - name: Environment Test
136
+ command: python
137
+ args:
138
+ - "-c"
139
+ - "import os; print(f'DB: {os.environ.get(\"DATABASE_URL\")}')"
140
+ expected:
141
+ return_code: 0
142
+ output_contains:
143
+ - "DB: sqlite:///test.db"
144
+
133
145
  - name: Directory Scan Test
134
146
  command: ls
135
147
  args:
@@ -440,6 +452,22 @@ This project is licensed under the MIT License - see the LICENSE file for detail
440
452
 
441
453
  ---
442
454
 
443
- **🚀 Ready to supercharge your testing workflow with parallel execution and advanced file comparison!**
455
+ ## 📚 Complete Documentation
456
+
457
+ For comprehensive documentation including detailed Setup Module guide, API reference, and advanced usage examples, see:
458
+
459
+ **[📖 Complete User Manual](docs/user_manual.md)**
460
+
461
+ The user manual includes:
462
+ - 🔧 **Setup Module**: Complete guide for environment variables and custom plugins
463
+ - 🚀 **Parallel Testing**: Advanced parallel execution strategies
464
+ - 📁 **File Comparison**: Detailed comparison capabilities for all file types
465
+ - 🔌 **API Reference**: Full API documentation and examples
466
+ - 🛠️ **Troubleshooting**: Common issues and solutions
467
+ - 📝 **Best Practices**: Recommended patterns and configurations
468
+
469
+ ---
470
+
471
+ **🚀 Ready to supercharge your testing workflow with setup modules, parallel execution and advanced file comparison!**
444
472
 
445
473
  For detailed parallel testing guide, see: [PARALLEL_TESTING_GUIDE.md](PARALLEL_TESTING_GUIDE.md)