cli-test-framework 0.2.2__tar.gz → 0.2.3__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 (54) hide show
  1. {cli_test_framework-0.2.2/src/cli_test_framework.egg-info → cli_test_framework-0.2.3}/PKG-INFO +1 -1
  2. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/setup.py +1 -1
  3. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/__init__.py +1 -1
  4. cli_test_framework-0.2.3/src/cli_test_framework/commands/__init__.py +9 -0
  5. cli_test_framework-0.2.3/src/cli_test_framework/commands/compare.py +180 -0
  6. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3/src/cli_test_framework.egg-info}/PKG-INFO +1 -1
  7. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework.egg-info/SOURCES.txt +2 -0
  8. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/CHANGELOG.md +0 -0
  9. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/MANIFEST.in +0 -0
  10. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/README.md +0 -0
  11. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/docs/user_manual.md +0 -0
  12. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/pyproject.toml +0 -0
  13. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/setup.cfg +0 -0
  14. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/cli.py +0 -0
  15. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/core/__init__.py +0 -0
  16. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/core/assertions.py +0 -0
  17. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/core/base_runner.py +0 -0
  18. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/core/parallel_runner.py +0 -0
  19. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/core/process_worker.py +0 -0
  20. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/core/test_case.py +0 -0
  21. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/__init__.py +0 -0
  22. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/base_comparator.py +0 -0
  23. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/binary_comparator.py +0 -0
  24. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/csv_comparator.py +0 -0
  25. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/factory.py +0 -0
  26. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/h5_comparator.py +0 -0
  27. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/json_comparator.py +0 -0
  28. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/result.py +0 -0
  29. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/text_comparator.py +0 -0
  30. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/file_comparator/xml_comparator.py +0 -0
  31. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/runners/__init__.py +0 -0
  32. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/runners/json_runner.py +0 -0
  33. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/runners/parallel_json_runner.py +0 -0
  34. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/runners/yaml_runner.py +0 -0
  35. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/utils/__init__.py +0 -0
  36. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/utils/path_resolver.py +0 -0
  37. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework/utils/report_generator.py +0 -0
  38. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework.egg-info/dependency_links.txt +0 -0
  39. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework.egg-info/entry_points.txt +0 -0
  40. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework.egg-info/requires.txt +0 -0
  41. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/src/cli_test_framework.egg-info/top_level.txt +0 -0
  42. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/__init__.py +0 -0
  43. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/__pycache__/__init__.cpython-312.pyc +0 -0
  44. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/__pycache__/test_parallel_runner.cpython-312-pytest-7.4.4.pyc +0 -0
  45. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/fixtures/test_cases.json +0 -0
  46. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/fixtures/test_cases.yaml +0 -0
  47. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/fixtures/test_cases1.json +0 -0
  48. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/performance_test.py +0 -0
  49. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/test1.py +0 -0
  50. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/test_comprehensive_space.py +0 -0
  51. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/test_parallel_runner.py +0 -0
  52. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/test_parallel_space.py +0 -0
  53. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/test_report.txt +0 -0
  54. {cli_test_framework-0.2.2 → cli_test_framework-0.2.3}/tests/test_runners.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cli-test-framework
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: A small command line testing framework in Python with file comparison capabilities.
5
5
  Home-page: https://github.com/yourusername/cli-test-framework
6
6
  Author: Xiaotong Wang
@@ -8,7 +8,7 @@ with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
8
8
 
9
9
  setup(
10
10
  name="cli-test-framework",
11
- version="0.2.2",
11
+ version="0.2.3",
12
12
  author="Xiaotong Wang",
13
13
  author_email="xiaotongwang98@gmail.com",
14
14
  description="A small command line testing framework in Python with file comparison capabilities.",
@@ -5,7 +5,7 @@ This package provides tools for testing command-line applications and scripts
5
5
  with support for parallel execution and advanced file comparison capabilities.
6
6
  """
7
7
 
8
- __version__ = "0.2.2"
8
+ __version__ = "0.2.3"
9
9
  __author__ = "Xiaotong Wang"
10
10
  __email__ = "xiaotongwang98@gmail.com"
11
11
 
@@ -0,0 +1,9 @@
1
+ """
2
+ Command-line commands for the CLI Testing Framework
3
+ """
4
+
5
+ from . import compare
6
+
7
+ __all__ = [
8
+ 'compare'
9
+ ]
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ @file compare.py
6
+ @brief Command for comparing files in cli-test-framework
7
+ @author Xiaotong Wang
8
+ @date 2024
9
+ """
10
+
11
+ import sys
12
+ import os
13
+ import argparse
14
+ import logging
15
+ from pathlib import Path
16
+ from ..file_comparator.factory import ComparatorFactory
17
+ from ..file_comparator.result import ComparisonResult
18
+
19
+ def configure_logging():
20
+ """Configure logging settings for the application"""
21
+ logger = logging.getLogger("cli_test_framework.file_comparator")
22
+ logger.setLevel(logging.INFO)
23
+
24
+ ch = logging.StreamHandler()
25
+ ch.setLevel(logging.INFO)
26
+ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
27
+ ch.setFormatter(formatter)
28
+ logger.addHandler(ch)
29
+
30
+ return logger
31
+
32
+ def parse_arguments():
33
+ """Parse command line arguments"""
34
+ parser = argparse.ArgumentParser(description="Compare two files.")
35
+ parser.add_argument("file1", help="Path to the first file")
36
+ parser.add_argument("file2", help="Path to the second file")
37
+ parser.add_argument("--start-line", type=int, default=1, help="Starting line number (1-based)")
38
+ parser.add_argument("--end-line", type=int, help="Ending line number (1-based)")
39
+ parser.add_argument("--start-column", type=int, default=1, help="Starting column number (1-based)")
40
+ parser.add_argument("--end-column", type=int, help="Ending column number (1-based)")
41
+ parser.add_argument("--file-type", help="Type of the files to compare", default="auto")
42
+ parser.add_argument("--encoding", default="utf-8", help="File encoding for text files")
43
+ parser.add_argument("--chunk-size", type=int, default=8192, help="Chunk size for binary comparison")
44
+ parser.add_argument("--output-format", choices=["text", "json", "html"], default="text",
45
+ help="Output format for the comparison result")
46
+ parser.add_argument("--verbose", "-v", action="store_true", help="Enable verbose output")
47
+ parser.add_argument("--debug", action="store_true", help="Enable debug mode with detailed logging")
48
+ parser.add_argument("--similarity", action="store_true",
49
+ help="When comparing binary files, compute and show similarity index")
50
+ parser.add_argument("--num-threads", type=int, default=4, help="Number of threads for parallel processing")
51
+
52
+ # JSON comparison options
53
+ json_group = parser.add_argument_group('JSON comparison options')
54
+ json_group.add_argument("--json-compare-mode", choices=["exact", "key-based"], default="exact",
55
+ help="JSON comparison mode: exact (default) or key-based")
56
+ json_group.add_argument("--json-key-field", help="Key field(s) to use for key-based JSON comparison")
57
+
58
+ # H5 comparison options
59
+ h5_group = parser.add_argument_group('HDF5 comparison options')
60
+ h5_group.add_argument("--h5-table", help="Comma-separated list of table names to compare in HDF5 files")
61
+ h5_group.add_argument("--h5-table-regex", help="Regular expression pattern to match table names in HDF5 files")
62
+ h5_group.add_argument("--h5-structure-only", action="store_true",
63
+ help="Only compare HDF5 file structure without comparing content")
64
+ h5_group.add_argument("--h5-show-content-diff", action="store_true",
65
+ help="Show detailed content differences when content differs")
66
+ h5_group.add_argument("--h5-rtol", type=float, default=1e-5,
67
+ help="Relative tolerance for numerical comparison in HDF5 files")
68
+ h5_group.add_argument("--h5-atol", type=float, default=1e-8,
69
+ help="Absolute tolerance for numerical comparison in HDF5 files")
70
+
71
+ return parser.parse_args()
72
+
73
+ def detect_file_type(file_path):
74
+ """Detect the type of file based on its extension"""
75
+ ext = file_path.suffix.lower()
76
+ if ext in ['.txt', '.py', '.md', '.json', '.xml', '.html', '.css', '.js']:
77
+ return 'text'
78
+ elif ext == '.json':
79
+ return 'json'
80
+ elif ext in ['.h5', '.hdf5']:
81
+ return 'h5'
82
+ else:
83
+ return 'binary'
84
+
85
+ def format_result(result, output_format):
86
+ """Format the comparison result according to the specified output format"""
87
+ if output_format == "json":
88
+ return result.to_json()
89
+ elif output_format == "html":
90
+ return result.to_html()
91
+ else:
92
+ return str(result)
93
+
94
+ def main():
95
+ """Main entry point for the compare-files command"""
96
+ logger = configure_logging()
97
+
98
+ try:
99
+ args = parse_arguments()
100
+
101
+ if args.debug:
102
+ logger.setLevel(logging.DEBUG)
103
+ logger.debug("Debug mode enabled")
104
+
105
+ # Adjust for 0-based indexing
106
+ start_line = max(0, args.start_line - 1)
107
+ end_line = None if args.end_line is None else max(0, args.end_line - 1)
108
+ start_column = max(0, args.start_column - 1)
109
+ end_column = None if args.end_column is None else max(0, args.end_column - 1)
110
+
111
+ # Resolve file paths
112
+ file1_path = Path(args.file1).resolve()
113
+ file2_path = Path(args.file2).resolve()
114
+
115
+ if not file1_path.exists():
116
+ raise ValueError(f"File not found: {file1_path}")
117
+ if not file2_path.exists():
118
+ raise ValueError(f"File not found: {file2_path}")
119
+
120
+ # Determine file type
121
+ file_type = args.file_type
122
+ if file_type == "auto":
123
+ file_type = detect_file_type(file1_path)
124
+ logger.info(f"Auto-detected file type: {file_type}")
125
+
126
+ # Prepare comparator kwargs
127
+ comparator_kwargs = {
128
+ "encoding": args.encoding,
129
+ "chunk_size": args.chunk_size,
130
+ "verbose": args.verbose or args.debug,
131
+ "num_threads": args.num_threads
132
+ }
133
+
134
+ # Add file type specific arguments
135
+ if file_type == "json":
136
+ comparator_kwargs["compare_mode"] = args.json_compare_mode
137
+ if args.json_key_field:
138
+ key_fields = [field.strip() for field in args.json_key_field.split(',')]
139
+ comparator_kwargs["key_field"] = key_fields[0] if len(key_fields) == 1 else key_fields
140
+
141
+ if file_type == "h5":
142
+ if args.h5_table:
143
+ tables = [table.strip() for table in args.h5_table.split(',')]
144
+ comparator_kwargs["tables"] = tables
145
+ if args.h5_table_regex:
146
+ comparator_kwargs["table_regex"] = args.h5_table_regex
147
+ comparator_kwargs["structure_only"] = args.h5_structure_only
148
+ comparator_kwargs["show_content_diff"] = args.h5_show_content_diff
149
+ comparator_kwargs["rtol"] = args.h5_rtol
150
+ comparator_kwargs["atol"] = args.h5_atol
151
+
152
+ if file_type == "binary":
153
+ comparator_kwargs["similarity"] = args.similarity
154
+
155
+ # Create comparator and perform comparison
156
+ comparator = ComparatorFactory.create_comparator(file_type, **comparator_kwargs)
157
+ result = comparator.compare_files(
158
+ file1_path,
159
+ file2_path,
160
+ start_line,
161
+ end_line,
162
+ start_column,
163
+ end_column
164
+ )
165
+
166
+ # Output result
167
+ output = format_result(result, args.output_format)
168
+ print(output)
169
+
170
+ sys.exit(0 if result.identical else 1)
171
+
172
+ except ValueError as ve:
173
+ logger.error(f"ValueError: {ve}")
174
+ sys.exit(1)
175
+ except Exception as e:
176
+ logger.exception(f"An unexpected error occurred")
177
+ sys.exit(1)
178
+
179
+ if __name__ == "__main__":
180
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cli-test-framework
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: A small command line testing framework in Python with file comparison capabilities.
5
5
  Home-page: https://github.com/yourusername/cli-test-framework
6
6
  Author: Xiaotong Wang
@@ -12,6 +12,8 @@ src/cli_test_framework.egg-info/dependency_links.txt
12
12
  src/cli_test_framework.egg-info/entry_points.txt
13
13
  src/cli_test_framework.egg-info/requires.txt
14
14
  src/cli_test_framework.egg-info/top_level.txt
15
+ src/cli_test_framework/commands/__init__.py
16
+ src/cli_test_framework/commands/compare.py
15
17
  src/cli_test_framework/core/__init__.py
16
18
  src/cli_test_framework/core/assertions.py
17
19
  src/cli_test_framework/core/base_runner.py