codecraftai-testbase 1.3.0__py3-none-any.whl

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 (142) hide show
  1. ccai/factories/py.typed +0 -0
  2. ccai/factories/testbasedefaulttypefactory.py +25 -0
  3. ccai/testbase/__init__.py +63 -0
  4. ccai/testbase/breakpoints.py +110 -0
  5. ccai/testbase/cli/__init__.py +13 -0
  6. ccai/testbase/cli/cmdtree/agents/__init__.py +28 -0
  7. ccai/testbase/cli/cmdtree/agents/config/__init__.py +24 -0
  8. ccai/testbase/cli/cmdtree/agents/config/extract.py +94 -0
  9. ccai/testbase/cli/cmdtree/agents/formatting.py +71 -0
  10. ccai/testbase/cli/cmdtree/agents/jsosparser.py +119 -0
  11. ccai/testbase/cli/cmdtree/agents/pathresolver.py +34 -0
  12. ccai/testbase/cli/cmdtree/agents/summary/__init__.py +26 -0
  13. ccai/testbase/cli/cmdtree/agents/summary/compare.py +128 -0
  14. ccai/testbase/cli/cmdtree/agents/summary/extract.py +91 -0
  15. ccai/testbase/cli/cmdtree/agents/testresult/__init__.py +28 -0
  16. ccai/testbase/cli/cmdtree/agents/testresult/extract.py +77 -0
  17. ccai/testbase/cli/cmdtree/agents/testresult/failures.py +73 -0
  18. ccai/testbase/cli/cmdtree/agents/testresult/list.py +63 -0
  19. ccai/testbase/cli/cmdtree/services/__init__.py +27 -0
  20. ccai/testbase/cli/cmdtree/services/results.py +66 -0
  21. ccai/testbase/cli/cmdtree/testing/__init__.py +30 -0
  22. ccai/testbase/cli/cmdtree/testing/jobs.py +175 -0
  23. ccai/testbase/cli/cmdtree/testing/query.py +131 -0
  24. ccai/testbase/cli/cmdtree/testing/run.py +263 -0
  25. ccai/testbase/cli/cmdtree/utilities/__init__.py +28 -0
  26. ccai/testbase/cli/cmdtree/utilities/timestamp.py +33 -0
  27. ccai/testbase/cli/options.py +370 -0
  28. ccai/testbase/cli/testbase_command.py +64 -0
  29. ccai/testbase/cli/utilities.py +31 -0
  30. ccai/testbase/configuration.py +324 -0
  31. ccai/testbase/constraints.py +998 -0
  32. ccai/testbase/coupling/__init__.py +569 -0
  33. ccai/testbase/coupling/basecoupling.py +69 -0
  34. ccai/testbase/coupling/configurationcoupling.py +138 -0
  35. ccai/testbase/coupling/integrationcoupling.py +842 -0
  36. ccai/testbase/coupling/validatorcoupling.py +127 -0
  37. ccai/testbase/debuggingext.py +281 -0
  38. ccai/testbase/debuglogging.py +407 -0
  39. ccai/testbase/debugports.py +469 -0
  40. ccai/testbase/declaration/__init__.py +13 -0
  41. ccai/testbase/declaration/attachments.py +222 -0
  42. ccai/testbase/declaration/originations.py +217 -0
  43. ccai/testbase/declaration/parameterization.py +160 -0
  44. ccai/testbase/declaration/registrations.py +476 -0
  45. ccai/testbase/diagnostic_level.py +197 -0
  46. ccai/testbase/diagnostic_streaming.py +1534 -0
  47. ccai/testbase/diagnostics.py +1685 -0
  48. ccai/testbase/entrypoints.py +485 -0
  49. ccai/testbase/environment.py +162 -0
  50. ccai/testbase/errors/testruntimeouterror.py +50 -0
  51. ccai/testbase/expressions.py +355 -0
  52. ccai/testbase/factories.py +277 -0
  53. ccai/testbase/factoryprotocols.py +35 -0
  54. ccai/testbase/features.py +913 -0
  55. ccai/testbase/initialize.py +210 -0
  56. ccai/testbase/injection/__init__.py +25 -0
  57. ccai/testbase/injection/injectiongroup.py +493 -0
  58. ccai/testbase/injection/injectionmoment.py +155 -0
  59. ccai/testbase/injection/injectionregistry.py +823 -0
  60. ccai/testbase/injection/injectionscope.py +2589 -0
  61. ccai/testbase/injection/introspection.py +514 -0
  62. ccai/testbase/markers.py +665 -0
  63. ccai/testbase/mocking.py +4856 -0
  64. ccai/testbase/origins/__init__.py +13 -0
  65. ccai/testbase/origins/resourceorigin.py +110 -0
  66. ccai/testbase/origins/validatororigin.py +111 -0
  67. ccai/testbase/output/__init__.py +17 -0
  68. ccai/testbase/output/outputcontext.py +201 -0
  69. ccai/testbase/output/runmetadata.py +184 -0
  70. ccai/testbase/properties/__init__.py +40 -0
  71. ccai/testbase/properties/assumptions.py +56 -0
  72. ccai/testbase/properties/decorators.py +173 -0
  73. ccai/testbase/properties/propertyrunner.py +449 -0
  74. ccai/testbase/properties/strategies.py +1592 -0
  75. ccai/testbase/properties/unittestsupport.py +87 -0
  76. ccai/testbase/py.typed +0 -0
  77. ccai/testbase/queries.py +95 -0
  78. ccai/testbase/resourcelifespan.py +24 -0
  79. ccai/testbase/results/__init__.py +35 -0
  80. ccai/testbase/results/exceptions.py +60 -0
  81. ccai/testbase/results/filtering/__init__.py +26 -0
  82. ccai/testbase/results/filtering/resultfilter.py +570 -0
  83. ccai/testbase/results/model/__init__.py +32 -0
  84. ccai/testbase/results/model/buildinfo.py +54 -0
  85. ccai/testbase/results/model/checkresult.py +183 -0
  86. ccai/testbase/results/model/forwardinginfo.py +30 -0
  87. ccai/testbase/results/model/jobcontainer.py +32 -0
  88. ccai/testbase/results/model/jobinfo.py +91 -0
  89. ccai/testbase/results/model/nestedprogressinfo.py +211 -0
  90. ccai/testbase/results/model/pipelineinfo.py +51 -0
  91. ccai/testbase/results/model/progressaggregator.py +551 -0
  92. ccai/testbase/results/model/progresscode.py +29 -0
  93. ccai/testbase/results/model/progressdelivery.py +51 -0
  94. ccai/testbase/results/model/progressinfo.py +84 -0
  95. ccai/testbase/results/model/progresstype.py +24 -0
  96. ccai/testbase/results/model/renderinfo.py +30 -0
  97. ccai/testbase/results/model/resultcode.py +28 -0
  98. ccai/testbase/results/model/resultcontainer.py +95 -0
  99. ccai/testbase/results/model/resultnode.py +258 -0
  100. ccai/testbase/results/model/resulttype.py +34 -0
  101. ccai/testbase/results/model/streaminginfo.py +111 -0
  102. ccai/testbase/results/model/taskinggroup.py +85 -0
  103. ccai/testbase/results/model/taskingresult.py +297 -0
  104. ccai/testbase/results/model/testcontainer.py +35 -0
  105. ccai/testbase/results/model/testresult.py +170 -0
  106. ccai/testbase/results/recorders/__init__.py +31 -0
  107. ccai/testbase/results/recorders/csvresultrecorder.py +414 -0
  108. ccai/testbase/results/recorders/jsonresultrecorder.py +467 -0
  109. ccai/testbase/results/recorders/resultrecorder.py +1472 -0
  110. ccai/testbase/results/recorders/stdoutresultrecorder.py +70 -0
  111. ccai/testbase/results/recorders/xmlresultrecorder.py +305 -0
  112. ccai/testbase/results/utilities.py +141 -0
  113. ccai/testbase/sequencing/__init__.py +13 -0
  114. ccai/testbase/sequencing/sequencermodulescope.py +96 -0
  115. ccai/testbase/sequencing/sequencerscopebase.py +91 -0
  116. ccai/testbase/sequencing/sequencersessionscope.py +84 -0
  117. ccai/testbase/sequencing/sequencertestscope.py +249 -0
  118. ccai/testbase/sequencing/sequencertestsetupscope.py +86 -0
  119. ccai/testbase/sequencing/testactivity.py +111 -0
  120. ccai/testbase/sequencing/testsequencer.py +3072 -0
  121. ccai/testbase/server/__init__.py +13 -0
  122. ccai/testbase/server/resultserver.py +599 -0
  123. ccai/testbase/sources/__init__.py +13 -0
  124. ccai/testbase/sources/configurationsource.py +32 -0
  125. ccai/testbase/sources/integrationsource.py +29 -0
  126. ccai/testbase/sources/resourcesource.py +27 -0
  127. ccai/testbase/sources/sourcebase.py +71 -0
  128. ccai/testbase/sources/unknownsource.py +30 -0
  129. ccai/testbase/sources/validatorsource.py +28 -0
  130. ccai/testbase/tandem/__init__.py +13 -0
  131. ccai/testbase/tandem/validators.py +286 -0
  132. ccai/testbase/testcollector.py +230 -0
  133. ccai/testbase/testgroup.py +54 -0
  134. ccai/testbase/testjob.py +600 -0
  135. ccai/testbase/testref.py +64 -0
  136. ccai/testbase/utilities.py +472 -0
  137. ccai/testbase/verification.py +768 -0
  138. codecraftai_testbase-1.3.0.dist-info/METADATA +99 -0
  139. codecraftai_testbase-1.3.0.dist-info/RECORD +142 -0
  140. codecraftai_testbase-1.3.0.dist-info/WHEEL +4 -0
  141. codecraftai_testbase-1.3.0.dist-info/entry_points.txt +3 -0
  142. codecraftai_testbase-1.3.0.dist-info/licenses/LICENSE.md +204 -0
@@ -0,0 +1,324 @@
1
+ """
2
+ .. module:: ccai.testbase.configuration
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for loading test entry point configuration from files.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+
8
+ This module provides functionality for loading default test entry point options
9
+ from configuration files. It supports a hierarchical configuration system with
10
+ user-level and project-level configuration files.
11
+
12
+ Configuration File Locations:
13
+ - User-level: ``~/.ccai/testbase.yaml`` or ``~/.ccai/testbase.yml``
14
+ - Project-level: ``.testbase.yaml`` or ``.testbase.yml`` in the current directory
15
+ or any parent directory up to the filesystem root
16
+
17
+ Configuration Precedence (highest to lowest):
18
+ 1. Command-line arguments (always override)
19
+ 2. Project-level configuration (closer to current directory wins)
20
+ 3. User-level configuration
21
+ 4. Built-in defaults
22
+
23
+ Supported Configuration Options:
24
+ - ``includes``: List of include expressions for test filtering
25
+ - ``excludes``: List of exclude expressions for test filtering
26
+ - ``console_level``: Logging level for console output
27
+ - ``logfile_level``: Logging level for file output
28
+
29
+ Example Configuration File::
30
+
31
+ # .testbase.yaml
32
+ includes:
33
+ - "test_unit_*"
34
+ - "test_integration_*"
35
+ excludes:
36
+ - "test_slow_*"
37
+ console_level: INFO
38
+ logfile_level: DEBUG
39
+
40
+ """
41
+
42
+ __author__ = "Myron Walker"
43
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
44
+ __credits__ = []
45
+
46
+
47
+ from typing import Any, Dict, List, Optional
48
+
49
+ import os
50
+
51
+ try:
52
+ import yaml
53
+ YAML_AVAILABLE = True
54
+ except ImportError:
55
+ YAML_AVAILABLE = False
56
+
57
+
58
+ # Configuration file names to search for
59
+ CONFIG_FILE_NAMES = [".testbase.yaml", ".testbase.yml"]
60
+
61
+ # User-level configuration directory and file names
62
+ USER_CONFIG_DIR = ".ccai"
63
+ USER_CONFIG_FILE_NAMES = ["testbase.yaml", "testbase.yml"]
64
+
65
+
66
+ class EntryPointConfiguration:
67
+ """
68
+ Container for test entry point configuration options.
69
+
70
+ This class holds the configuration values loaded from configuration files
71
+ and provides a clean interface for accessing them.
72
+
73
+ Attributes:
74
+ includes (List[str]): List of include expressions for test filtering.
75
+ excludes (List[str]): List of exclude expressions for test filtering.
76
+ console_level (Optional[str]): Logging level for console output.
77
+ logfile_level (Optional[str]): Logging level for file output.
78
+ """
79
+
80
+ def __init__(self):
81
+ """Initialize an empty configuration."""
82
+ self.includes: List[str] = []
83
+ self.excludes: List[str] = []
84
+ self.console_level: Optional[str] = None
85
+ self.logfile_level: Optional[str] = None
86
+
87
+ def merge(self, other: "EntryPointConfiguration") -> None:
88
+ """
89
+ Merge another configuration into this one.
90
+
91
+ Values from the other configuration override values in this configuration
92
+ only if they are set (non-empty for lists, non-None for scalars).
93
+
94
+ :param other: The configuration to merge into this one.
95
+ :type other: EntryPointConfiguration
96
+ """
97
+ if other.includes:
98
+ self.includes = other.includes
99
+ if other.excludes:
100
+ self.excludes = other.excludes
101
+ if other.console_level is not None:
102
+ self.console_level = other.console_level
103
+ if other.logfile_level is not None:
104
+ self.logfile_level = other.logfile_level
105
+
106
+ def __repr__(self) -> str:
107
+ return (
108
+ f"EntryPointConfiguration(includes={self.includes}, "
109
+ f"excludes={self.excludes}, console_level={self.console_level}, "
110
+ f"logfile_level={self.logfile_level})"
111
+ )
112
+
113
+
114
+ def _load_yaml_file(filepath: str) -> Optional[Dict[str, Any]]:
115
+ """
116
+ Load and parse a YAML configuration file.
117
+
118
+ :param filepath: Path to the YAML file to load.
119
+ :type filepath: str
120
+
121
+ :returns: Parsed YAML content as a dictionary, or None if the file
122
+ cannot be loaded or parsed.
123
+ :rtype: Optional[Dict[str, Any]]
124
+ """
125
+ if not YAML_AVAILABLE:
126
+ return None
127
+
128
+ if not os.path.isfile(filepath):
129
+ return None
130
+
131
+ try:
132
+ with open(filepath, 'r', encoding='utf-8') as f:
133
+ content = yaml.safe_load(f)
134
+ if isinstance(content, dict):
135
+ return content
136
+ except (yaml.YAMLError, IOError, OSError):
137
+ # Silently ignore configuration file errors
138
+ pass
139
+
140
+ return None
141
+
142
+
143
+ def _parse_config_dict(config_dict: Dict[str, Any]) -> EntryPointConfiguration:
144
+ """
145
+ Parse a configuration dictionary into an EntryPointConfiguration object.
146
+
147
+ :param config_dict: Dictionary containing configuration values.
148
+ :type config_dict: Dict[str, Any]
149
+
150
+ :returns: Parsed configuration object.
151
+ :rtype: EntryPointConfiguration
152
+ """
153
+ config = EntryPointConfiguration()
154
+
155
+ # Parse includes
156
+ includes = config_dict.get("includes")
157
+ if isinstance(includes, list):
158
+ config.includes = [str(item) for item in includes if item is not None]
159
+ elif isinstance(includes, str):
160
+ config.includes = [includes]
161
+
162
+ # Parse excludes
163
+ excludes = config_dict.get("excludes")
164
+ if isinstance(excludes, list):
165
+ config.excludes = [str(item) for item in excludes if item is not None]
166
+ elif isinstance(excludes, str):
167
+ config.excludes = [excludes]
168
+
169
+ # Parse console_level
170
+ console_level = config_dict.get("console_level")
171
+ if isinstance(console_level, str):
172
+ config.console_level = console_level.upper()
173
+
174
+ # Parse logfile_level
175
+ logfile_level = config_dict.get("logfile_level")
176
+ if isinstance(logfile_level, str):
177
+ config.logfile_level = logfile_level.upper()
178
+
179
+ return config
180
+
181
+
182
+ def find_user_config_file() -> Optional[str]:
183
+ """
184
+ Find the user-level configuration file.
185
+
186
+ Searches for configuration files in the user's home directory under
187
+ the ``.ccai`` directory.
188
+
189
+ :returns: Path to the user configuration file if found, None otherwise.
190
+ :rtype: Optional[str]
191
+ """
192
+ home_dir = os.path.expanduser("~")
193
+ config_dir = os.path.join(home_dir, USER_CONFIG_DIR)
194
+
195
+ if not os.path.isdir(config_dir):
196
+ return None
197
+
198
+ for filename in USER_CONFIG_FILE_NAMES:
199
+ filepath = os.path.join(config_dir, filename)
200
+ if os.path.isfile(filepath):
201
+ return filepath
202
+
203
+ return None
204
+
205
+
206
+ def find_project_config_file(start_dir: Optional[str] = None) -> Optional[str]:
207
+ """
208
+ Find the project-level configuration file.
209
+
210
+ Searches for configuration files starting from the specified directory
211
+ (or current working directory) and walking up to the filesystem root.
212
+
213
+ :param start_dir: Directory to start searching from. Defaults to the
214
+ current working directory.
215
+ :type start_dir: Optional[str]
216
+
217
+ :returns: Path to the project configuration file if found, None otherwise.
218
+ :rtype: Optional[str]
219
+ """
220
+ if start_dir is None:
221
+ start_dir = os.getcwd()
222
+
223
+ current_dir = os.path.abspath(start_dir)
224
+
225
+ while True:
226
+ for filename in CONFIG_FILE_NAMES:
227
+ filepath = os.path.join(current_dir, filename)
228
+ if os.path.isfile(filepath):
229
+ return filepath
230
+
231
+ parent_dir = os.path.dirname(current_dir)
232
+ if parent_dir == current_dir:
233
+ # Reached filesystem root
234
+ break
235
+ current_dir = parent_dir
236
+
237
+ return None
238
+
239
+
240
+ def load_user_configuration() -> EntryPointConfiguration:
241
+ """
242
+ Load user-level configuration.
243
+
244
+ Searches for and loads the user-level configuration file from
245
+ ``~/.ccai/testbase.yaml`` or ``~/.ccai/testbase.yml``.
246
+
247
+ :returns: Configuration loaded from the user config file, or an empty
248
+ configuration if no file is found.
249
+ :rtype: EntryPointConfiguration
250
+ """
251
+ config = EntryPointConfiguration()
252
+
253
+ config_file = find_user_config_file()
254
+ if config_file is not None:
255
+ config_dict = _load_yaml_file(config_file)
256
+ if config_dict is not None:
257
+ config = _parse_config_dict(config_dict)
258
+
259
+ return config
260
+
261
+
262
+ def load_project_configuration(start_dir: Optional[str] = None) -> EntryPointConfiguration:
263
+ """
264
+ Load project-level configuration.
265
+
266
+ Searches for and loads the project-level configuration file from
267
+ ``.testbase.yaml`` or ``.testbase.yml`` in the current directory
268
+ or any parent directory.
269
+
270
+ :param start_dir: Directory to start searching from. Defaults to the
271
+ current working directory.
272
+ :type start_dir: Optional[str]
273
+
274
+ :returns: Configuration loaded from the project config file, or an empty
275
+ configuration if no file is found.
276
+ :rtype: EntryPointConfiguration
277
+ """
278
+ config = EntryPointConfiguration()
279
+
280
+ config_file = find_project_config_file(start_dir)
281
+ if config_file is not None:
282
+ config_dict = _load_yaml_file(config_file)
283
+ if config_dict is not None:
284
+ config = _parse_config_dict(config_dict)
285
+
286
+ return config
287
+
288
+
289
+ def load_entrypoint_configuration(start_dir: Optional[str] = None) -> EntryPointConfiguration:
290
+ """
291
+ Load merged configuration from all sources.
292
+
293
+ Loads configuration from user-level and project-level configuration files
294
+ and merges them according to the precedence rules. Project-level configuration
295
+ takes precedence over user-level configuration.
296
+
297
+ :param start_dir: Directory to start searching for project configuration.
298
+ Defaults to the current working directory.
299
+ :type start_dir: Optional[str]
300
+
301
+ :returns: Merged configuration from all sources.
302
+ :rtype: EntryPointConfiguration
303
+
304
+ Example:
305
+ Loading configuration for use in the entry point::
306
+
307
+ from ccai.testbase.configuration import load_entrypoint_configuration
308
+
309
+ config = load_entrypoint_configuration()
310
+
311
+ # Use configuration values
312
+ includes = config.includes or ["*"]
313
+ excludes = config.excludes or []
314
+ console_level = config.console_level or "INFO"
315
+ logfile_level = config.logfile_level or "DEBUG"
316
+ """
317
+ # Start with user-level configuration
318
+ config = load_user_configuration()
319
+
320
+ # Merge project-level configuration (takes precedence)
321
+ project_config = load_project_configuration(start_dir)
322
+ config.merge(project_config)
323
+
324
+ return config