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,13 @@
1
+ """
2
+ .. module:: ccai.testbase.origins
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for origins.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+ """
8
+
9
+ __author__ = "Myron Walker"
10
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
11
+ __credits__ = []
12
+
13
+
@@ -0,0 +1,110 @@
1
+ """
2
+ .. module:: ccai.testbase.origins.resourceorigin
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for resourceorigin.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+ """
8
+
9
+
10
+
11
+ __author__ = "Myron Walker"
12
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
13
+ __credits__ = []
14
+
15
+
16
+
17
+ from typing import Callable, Dict, Optional, Type
18
+
19
+ import inspect
20
+
21
+ from ccai.testbase.constraints import ConstraintsCatalog, ConstraintsOrigin
22
+ from ccai.testbase.sources.sourcebase import SourceBase
23
+ from ccai.testbase.resourcelifespan import ResourceLifespan
24
+
25
+ constraints_catalog = ConstraintsCatalog()
26
+
27
+ class ResourceOrigin:
28
+ """
29
+ Describes the origin of a resource provider in the injection tree.
30
+ """
31
+
32
+ def __init__(self, originating_scope: str, identifier: str, life_span: ResourceLifespan,
33
+ source: Optional[SourceBase] = None, implied: bool = False,
34
+ constraints: Optional[Dict] = None):
35
+ self._originating_scope = originating_scope
36
+ self._identifier = identifier
37
+ self._life_span = life_span
38
+ self._source = source
39
+ self._implied = implied
40
+
41
+ self._constraints_key = None
42
+ if constraints is not None:
43
+ self._constraints_key = constraints_catalog.add_constraints(ConstraintsOrigin.SITE_PARAMETER, originating_scope, identifier, constraints)
44
+ return
45
+
46
+ @property
47
+ def constraints_key(self) -> str:
48
+ return self._constraints_key
49
+
50
+ @property
51
+ def identifier(self) -> str:
52
+ return self._identifier
53
+
54
+ @property
55
+ def implied(self) -> bool:
56
+ return self._implied
57
+
58
+ @property
59
+ def life_span(self) -> ResourceLifespan:
60
+ return self._life_span
61
+
62
+ @property
63
+ def originating_scope(self) -> str:
64
+ return self._originating_scope
65
+
66
+ @property
67
+ def source_function(self) -> Callable:
68
+ return self._source.source_function
69
+
70
+ @property
71
+ def source_function_name(self) -> str:
72
+ return self._source.source_function.__name__
73
+
74
+ @property
75
+ def source_signature(self) -> inspect.Signature:
76
+ return self._source.source_signature
77
+
78
+ @property
79
+ def source_id(self) -> str:
80
+ idstr = self._source.source_id
81
+ return idstr
82
+
83
+ @property
84
+ def source_module_name(self) -> str:
85
+ return self._source.module_name
86
+
87
+ @property
88
+ def source_resource_type(self) -> Type:
89
+ return self._source.resource_type
90
+
91
+ def describe_source(self):
92
+ descstr = self.source_id
93
+ cval = self.constraints_key
94
+ if cval is not None:
95
+ descstr += " constraints={}".format(repr(cval))
96
+ return descstr
97
+
98
+ def generate_call(self, constraints: Optional[dict] = None):
99
+ call_arg_str = ""
100
+
101
+ call_args = [param for param in self.source_signature.parameters]
102
+ if constraints is None and "constraints" in call_args:
103
+ call_args.remove("constraints")
104
+
105
+ if len(call_args) > 0:
106
+ call_arg_str = ", ".join(call_args)
107
+
108
+ call_str = "{}({})".format(self._source.source_function.__name__, call_arg_str)
109
+
110
+ return call_str
@@ -0,0 +1,111 @@
1
+ """
2
+ .. module:: ccai.testbase.origins.validatororigin
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for validatororigin.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+ """
8
+
9
+
10
+
11
+ __author__ = "Myron Walker"
12
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
13
+ __credits__ = []
14
+ __version__ = "1.0.0"
15
+
16
+
17
+ from typing import Callable, Dict, Optional, Type
18
+
19
+ import inspect
20
+
21
+ from ccai.testbase.constraints import ConstraintsCatalog, ConstraintsOrigin
22
+ from ccai.testbase.sources.sourcebase import SourceBase
23
+ from ccai.testbase.resourcelifespan import ResourceLifespan
24
+
25
+ constraints_catalog = ConstraintsCatalog()
26
+
27
+ class ValidatorOrigin:
28
+ """
29
+ Describes the origin of a validator used during testing.
30
+ """
31
+
32
+ def __init__(self, originating_scope: str, identifier: str, suffix: str, source: Optional[SourceBase] = None,
33
+ implied: bool = False, constraints: Optional[Dict] = None):
34
+ self._originating_scope = originating_scope
35
+ self._identifier = identifier
36
+ self._suffix = suffix
37
+ self._life_span = ResourceLifespan.Test
38
+ self._source = source
39
+ self._implied = implied
40
+
41
+ self._constraints_key = None
42
+ if constraints is not None:
43
+ self._constraints_key = constraints_catalog.add_constraints(ConstraintsOrigin.SITE_PARAMETER, originating_scope, identifier, constraints)
44
+ return
45
+
46
+ @property
47
+ def constraints_key(self) -> str:
48
+ return self._constraints_key
49
+
50
+ @property
51
+ def identifier(self) -> str:
52
+ return self._identifier
53
+
54
+ @property
55
+ def implied(self) -> bool:
56
+ return self._implied
57
+
58
+ @property
59
+ def life_span(self) -> ResourceLifespan:
60
+ return self._life_span
61
+
62
+ @property
63
+ def originating_scope(self) -> str:
64
+ return self._originating_scope
65
+
66
+ @property
67
+ def source_function(self) -> Callable:
68
+ return self._source.source_function
69
+
70
+ @property
71
+ def source_function_name(self) -> str:
72
+ return self._source.source_function.__name__
73
+
74
+ @property
75
+ def source_signature(self) -> inspect.Signature:
76
+ return self._source.source_signature
77
+
78
+ @property
79
+ def source_id(self) -> str:
80
+ idstr = self._source.source_id
81
+ return idstr
82
+
83
+ @property
84
+ def source_module_name(self) -> str:
85
+ return self._source.module_name
86
+
87
+ @property
88
+ def source_resource_type(self) -> Type:
89
+ return self._source.resource_type
90
+
91
+ @property
92
+ def suffix(self) -> str:
93
+ return self._suffix
94
+
95
+ def describe_source(self):
96
+ descstr = self.source_id
97
+ return descstr
98
+
99
+ def generate_call(self, constraints: Optional[dict] = None):
100
+ call_arg_str = ""
101
+
102
+ call_args = [param for param in self.source_signature.parameters]
103
+ if constraints is None and "constraints" in call_args:
104
+ call_args.remove("constraints")
105
+
106
+ if len(call_args) > 0:
107
+ call_arg_str = ", ".join(call_args)
108
+
109
+ call_str = "{}({})".format(self._source.source_function.__name__, call_arg_str)
110
+
111
+ return call_str
@@ -0,0 +1,17 @@
1
+ """
2
+ .. package:: ccai.testbase.output
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Output-location and run-metadata seams that let the ``testbase`` core run
5
+ standalone (no dependency on ``codecraftai-runtime`` / ``codecraftai-this-app``).
6
+
7
+ The standalone defaults (:class:`SimpleOutputContext`, :class:`StandaloneRunMetadata`) are
8
+ used when ``testbase`` runs on its own. The integration layer
9
+ (``codecraftai-integration-runtime`` / ``IntegratedTestJob``) registers richer implementations
10
+ backed by ``ccai.thisapp`` well-known paths and ``RuntimeVariables``.
11
+
12
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
13
+ """
14
+
15
+ __author__ = "Myron Walker"
16
+ __copyright__ = "Copyright 2026, Code Craft AI LLC"
17
+ __credits__ = []
@@ -0,0 +1,201 @@
1
+ """
2
+ .. module:: ccai.testbase.output.outputcontext
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: The :class:`IOutputContext` seam and its standalone :class:`SimpleOutputContext`
5
+ default for resolving where ``testbase`` writes run artefacts.
6
+
7
+ The ``testbase`` core asks an :class:`IOutputContext` for the directories it needs (results,
8
+ per-testcase by-products, diagnostics) instead of importing the well-known-path helpers that
9
+ now live in ``ccai.thisapp.paths``. This keeps the framework dependency-free of the
10
+ runtime / this-app layers.
11
+
12
+ ``SimpleOutputContext`` is the standalone default: it roots everything under a single base
13
+ directory (``AM_OUTPUT_DIRECTORY`` or ``<cwd>/.output``). The integration runtime supplies a
14
+ ``RuntimeOutputContext`` (backed by ``ccai.thisapp.paths``) instead.
15
+
16
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
17
+ """
18
+
19
+ __author__ = "Myron Walker"
20
+ __copyright__ = "Copyright 2026, Code Craft AI LLC"
21
+ __credits__ = []
22
+
23
+
24
+ from abc import ABC, abstractmethod
25
+ from typing import Optional
26
+
27
+ import os
28
+
29
+ from ccai.testbase import environment
30
+
31
+
32
+ TRANSLATE_TABLE_NORMALIZE_FOR_PATH = str.maketrans(",.:;", " ")
33
+
34
+
35
+ def ensure_directory(target: str) -> None:
36
+ """
37
+ Creates a directory and any missing parents WITHOUT consulting
38
+ ``os.path.exists``.
39
+
40
+ ``os.makedirs`` internally checks ``os.path.exists`` to decide whether
41
+ a parent needs creating -- and ``os.path.exists`` is one of the most
42
+ commonly patched functions in tests. A resource factory that patches
43
+ it to return ``True`` makes ``os.makedirs`` skip a genuinely missing
44
+ parent and then fail with ``FileNotFoundError`` on the leaf, killing
45
+ the run from inside the framework. This helper only issues
46
+ ``os.mkdir`` calls and classifies the FILESYSTEM's own errors, so a
47
+ patched ``exists`` cannot mislead it in either direction.
48
+
49
+ :param target: The absolute directory path to create.
50
+ """
51
+ try:
52
+ os.mkdir(target)
53
+ except FileExistsError:
54
+ return
55
+ except FileNotFoundError:
56
+ parent = os.path.dirname(target)
57
+ if parent == target:
58
+ raise
59
+ ensure_directory(parent)
60
+ try:
61
+ os.mkdir(target)
62
+ except FileExistsError:
63
+ # Another creator made the directory after its parent was created; the
64
+ # directory now exists, which is the outcome this function guarantees.
65
+ pass
66
+ return
67
+
68
+
69
+ def normalize_name_for_path(name: str) -> str:
70
+ """
71
+ Normalises an identifier so it can be used as a path segment.
72
+
73
+ :param name: The identifier to normalise.
74
+
75
+ :returns: A filesystem-safe version of the identifier.
76
+ """
77
+ translated = name.translate(TRANSLATE_TABLE_NORMALIZE_FOR_PATH)
78
+ collapsed = "-".join(translated.split())
79
+ return collapsed
80
+
81
+
82
+ class IOutputContext(ABC):
83
+ """
84
+ Seam used by the ``testbase`` core to resolve the directories where run artefacts are
85
+ written. Implementations decide whether artefacts go under a simple base directory
86
+ (standalone) or under the well-known result paths managed by the integration runtime.
87
+ """
88
+
89
+ @abstractmethod
90
+ def get_test_results_dir(self) -> str:
91
+ """
92
+ Returns the directory where the top-level test-run artefacts are written.
93
+
94
+ :returns: An absolute path to the results directory (created if necessary).
95
+ """
96
+ raise NotImplementedError("IOutputContext.get_test_results_dir must be implemented")
97
+
98
+ @abstractmethod
99
+ def get_testcase_byproducts_dir(self, test_id: str) -> str:
100
+ """
101
+ Returns the directory where a single test case writes its by-products.
102
+
103
+ :param test_id: The scope identifier of the test case.
104
+
105
+ :returns: An absolute path to the test-case by-products directory (created if necessary).
106
+ """
107
+ raise NotImplementedError("IOutputContext.get_testcase_byproducts_dir must be implemented")
108
+
109
+ @abstractmethod
110
+ def get_diagnostics_dir(self, label: str) -> str:
111
+ """
112
+ Returns the directory where a diagnostic capture writes its artefacts.
113
+
114
+ :param label: A label identifying the diagnostic capture.
115
+
116
+ :returns: An absolute path to the diagnostics directory (created if necessary).
117
+ """
118
+ raise NotImplementedError("IOutputContext.get_diagnostics_dir must be implemented")
119
+
120
+ @abstractmethod
121
+ def get_summary_template_source(self) -> Optional[str]:
122
+ """
123
+ Returns the path to the HTML summary template, when HTML rendering is available.
124
+
125
+ :returns: A path to the template, or ``None`` for standalone (stdout) operation.
126
+ """
127
+ raise NotImplementedError("IOutputContext.get_summary_template_source must be implemented")
128
+
129
+ @abstractmethod
130
+ def get_static_resource_source(self) -> Optional[str]:
131
+ """
132
+ Returns the source directory for static render resources, when available.
133
+
134
+ :returns: A path, or ``None`` for standalone (stdout) operation.
135
+ """
136
+ raise NotImplementedError("IOutputContext.get_static_resource_source must be implemented")
137
+
138
+ @abstractmethod
139
+ def get_static_resource_destination(self) -> Optional[str]:
140
+ """
141
+ Returns the destination directory for static render resources, when available.
142
+
143
+ :returns: A path, or ``None`` for standalone (stdout) operation.
144
+ """
145
+ raise NotImplementedError("IOutputContext.get_static_resource_destination must be implemented")
146
+
147
+
148
+ class SimpleOutputContext(IOutputContext):
149
+ """
150
+ Standalone :class:`IOutputContext` that roots every artefact under a single base directory.
151
+
152
+ The base directory is, in order of precedence, the ``base_dir`` argument, the
153
+ ``AM_OUTPUT_DIRECTORY`` environment variable, or ``<cwd>/.output``. No HTML template or
154
+ static-resource paths are provided (standalone runs record to stdout), so the
155
+ template / static-resource accessors return ``None``.
156
+ """
157
+
158
+ def __init__(self, base_dir: Optional[str] = None):
159
+ """
160
+ Constructor for a :class:`SimpleOutputContext`.
161
+
162
+ :param base_dir: Optional explicit base directory for run artefacts.
163
+ """
164
+ resolved_base = base_dir
165
+ if resolved_base is None:
166
+ resolved_base = environment.get_output_directory()
167
+ if resolved_base is None:
168
+ resolved_base = os.path.join(os.getcwd(), ".output")
169
+
170
+ self._base_dir = os.path.abspath(resolved_base)
171
+ return
172
+
173
+ @property
174
+ def base_dir(self) -> str:
175
+ return self._base_dir
176
+
177
+ def get_test_results_dir(self) -> str:
178
+ results_dir = self._base_dir
179
+ ensure_directory(results_dir)
180
+ return results_dir
181
+
182
+ def get_testcase_byproducts_dir(self, test_id: str) -> str:
183
+ safe_id = normalize_name_for_path(test_id)
184
+ byproducts_dir = os.path.join(self._base_dir, "testcase_byproducts", safe_id)
185
+ ensure_directory(byproducts_dir)
186
+ return byproducts_dir
187
+
188
+ def get_diagnostics_dir(self, label: str) -> str:
189
+ safe_label = normalize_name_for_path(label)
190
+ diagnostics_dir = os.path.join(self._base_dir, "diagnostics", safe_label)
191
+ ensure_directory(diagnostics_dir)
192
+ return diagnostics_dir
193
+
194
+ def get_summary_template_source(self) -> Optional[str]:
195
+ return None
196
+
197
+ def get_static_resource_source(self) -> Optional[str]:
198
+ return None
199
+
200
+ def get_static_resource_destination(self) -> Optional[str]:
201
+ return None
@@ -0,0 +1,184 @@
1
+ """
2
+ .. module:: ccai.testbase.output.runmetadata
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: The :class:`IRunMetadata` seam and its standalone :class:`StandaloneRunMetadata`
5
+ default for the build / pipeline / job metadata associated with a test run.
6
+
7
+ The ``testbase`` core obtains run metadata from an :class:`IRunMetadata` instead of reading
8
+ the ``RuntimeVariables`` descriptor set (which now lives in ``ccai.thisapp`` and is used
9
+ only by the integration runtime). Standalone runs use :class:`StandaloneRunMetadata`, which
10
+ auto-generates a run id and fills CI/build/pipeline/job fields with ``(unknown)`` placeholders.
11
+
12
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
13
+ """
14
+
15
+ __author__ = "Myron Walker"
16
+ __copyright__ = "Copyright 2026, Code Craft AI LLC"
17
+ __credits__ = []
18
+
19
+
20
+ from abc import ABC, abstractmethod
21
+ from datetime import datetime
22
+ from typing import Optional
23
+
24
+ import uuid
25
+
26
+ from ccai.testbase import environment
27
+ from ccai.testbase.results.model.buildinfo import BuildInfo
28
+ from ccai.testbase.results.model.pipelineinfo import PipelineInfo
29
+ from ccai.testbase.results.model.jobinfo import JobInfo
30
+
31
+
32
+ UNKNOWN = "(unknown)"
33
+
34
+
35
+ class IRunMetadata(ABC):
36
+ """
37
+ Seam used by the ``testbase`` core to obtain the run-level metadata (run id, start time,
38
+ timeout, and the build / pipeline / job descriptors) for a test run. Implementations
39
+ decide whether the values come from CI environment / runtime variables (integration) or
40
+ from standalone defaults.
41
+ """
42
+
43
+ @property
44
+ @abstractmethod
45
+ def run_id(self) -> str:
46
+ """The unique identifier for this test run."""
47
+ raise NotImplementedError("IRunMetadata.run_id must be implemented")
48
+
49
+ @property
50
+ @abstractmethod
51
+ def apod(self) -> Optional[str]:
52
+ """The name of the automation pod the run executes on, when applicable."""
53
+ raise NotImplementedError("IRunMetadata.apod must be implemented")
54
+
55
+ @property
56
+ @abstractmethod
57
+ def title(self) -> str:
58
+ """A human-readable title for the test run."""
59
+ raise NotImplementedError("IRunMetadata.title must be implemented")
60
+
61
+ @property
62
+ @abstractmethod
63
+ def starttime(self) -> datetime:
64
+ """The start time of the test run."""
65
+ raise NotImplementedError("IRunMetadata.starttime must be implemented")
66
+
67
+ @property
68
+ @abstractmethod
69
+ def testrun_timeout(self) -> Optional[int]:
70
+ """The optional whole-run timeout, in seconds."""
71
+ raise NotImplementedError("IRunMetadata.testrun_timeout must be implemented")
72
+
73
+ @property
74
+ @abstractmethod
75
+ def job_seed(self) -> str:
76
+ """The job-level seed used for reproducible property testing."""
77
+ raise NotImplementedError("IRunMetadata.job_seed must be implemented")
78
+
79
+ @abstractmethod
80
+ def build_info(self) -> BuildInfo:
81
+ """
82
+ :returns: A :class:`BuildInfo` describing the build the run is associated with.
83
+ """
84
+ raise NotImplementedError("IRunMetadata.build_info must be implemented")
85
+
86
+ @abstractmethod
87
+ def pipeline_info(self) -> PipelineInfo:
88
+ """
89
+ :returns: A :class:`PipelineInfo` describing the pipeline the run is associated with.
90
+ """
91
+ raise NotImplementedError("IRunMetadata.pipeline_info must be implemented")
92
+
93
+ @abstractmethod
94
+ def job_info(self) -> JobInfo:
95
+ """
96
+ :returns: A :class:`JobInfo` describing the job the run is associated with.
97
+ """
98
+ raise NotImplementedError("IRunMetadata.job_info must be implemented")
99
+
100
+
101
+ class StandaloneRunMetadata(IRunMetadata):
102
+ """
103
+ Standalone :class:`IRunMetadata` for plain ``testbase`` runs.
104
+
105
+ The run id is taken from ``AM_RUN_ID`` or auto-generated; the start time defaults to the
106
+ construction time; the timeout is read from the environment; and the build / pipeline / job
107
+ descriptors are filled with ``(unknown)`` placeholders so the result model and stdout
108
+ summary remain well-formed without any CI/runtime context.
109
+ """
110
+
111
+ def __init__(self, run_id: Optional[str] = None, apod: Optional[str] = None,
112
+ title: str = "Test Run", starttime: Optional[datetime] = None,
113
+ testrun_timeout: Optional[int] = None):
114
+ """
115
+ Constructor for a :class:`StandaloneRunMetadata`.
116
+
117
+ :param run_id: Optional explicit run id (otherwise ``AM_RUN_ID`` or a new uuid).
118
+ :param apod: Optional automation-pod name.
119
+ :param title: A human-readable title for the run.
120
+ :param starttime: Optional explicit start time (otherwise the construction time).
121
+ :param testrun_timeout: Optional explicit timeout (otherwise read from the environment).
122
+ """
123
+ resolved_run_id = run_id
124
+ if resolved_run_id is None:
125
+ resolved_run_id = environment.get_run_id()
126
+ if resolved_run_id is None:
127
+ resolved_run_id = str(uuid.uuid4())
128
+ self._run_id = resolved_run_id
129
+
130
+ self._apod = apod
131
+
132
+ self._title = title
133
+
134
+ resolved_start = starttime
135
+ if resolved_start is None:
136
+ resolved_start = datetime.now()
137
+ self._starttime = resolved_start
138
+
139
+ resolved_timeout = testrun_timeout
140
+ if resolved_timeout is None:
141
+ resolved_timeout = environment.get_testrun_timeout()
142
+ self._testrun_timeout = resolved_timeout
143
+
144
+ self._job_seed = None
145
+ return
146
+
147
+ @property
148
+ def run_id(self) -> str:
149
+ return self._run_id
150
+
151
+ @property
152
+ def apod(self) -> Optional[str]:
153
+ return self._apod
154
+
155
+ @property
156
+ def title(self) -> str:
157
+ return self._title
158
+
159
+ @property
160
+ def starttime(self) -> datetime:
161
+ return self._starttime
162
+
163
+ @property
164
+ def testrun_timeout(self) -> Optional[int]:
165
+ return self._testrun_timeout
166
+
167
+ @property
168
+ def job_seed(self) -> str:
169
+ if self._job_seed is None:
170
+ self._job_seed = str(uuid.uuid4())
171
+ return self._job_seed
172
+
173
+ def build_info(self) -> BuildInfo:
174
+ info = BuildInfo(branch=UNKNOWN, build=UNKNOWN, flavor=UNKNOWN, release=UNKNOWN, url=UNKNOWN)
175
+ return info
176
+
177
+ def pipeline_info(self) -> PipelineInfo:
178
+ info = PipelineInfo(id=UNKNOWN, name=UNKNOWN, instance=UNKNOWN)
179
+ return info
180
+
181
+ def job_info(self) -> JobInfo:
182
+ info = JobInfo(id=UNKNOWN, name=self._title, type=UNKNOWN, owner=UNKNOWN, label=UNKNOWN,
183
+ initiator=UNKNOWN, venue=UNKNOWN, seed=self.job_seed, tag=UNKNOWN)
184
+ return info
@@ -0,0 +1,40 @@
1
+ """
2
+ .. module:: ccai.testbase.properties
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Property-based testing support for TestBase.
5
+
6
+ This package provides a built-in, stdlib-only property testing engine
7
+ for the TestBase framework. It enables test authors to declare invariants
8
+ via the ``@given`` decorator and strategies, which are then verified
9
+ against randomly generated inputs.
10
+
11
+ **Quick Start**::
12
+
13
+ from ccai.testbase.properties import given
14
+ from ccai.testbase.properties import strategies as st
15
+
16
+ @given(x=st.integers(), y=st.integers())
17
+ def test_addition_commutative(x, y):
18
+ assert x + y == y + x
19
+
20
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
21
+ """
22
+
23
+
24
+
25
+ __author__ = "Myron Walker"
26
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
27
+ __credits__ = []
28
+
29
+
30
+ from ccai.testbase.properties.decorators import (
31
+ given,
32
+ expect_exception
33
+ )
34
+
35
+ from ccai.testbase.properties.assumptions import assume
36
+
37
+ from ccai.testbase.properties.unittestsupport import run_property
38
+
39
+ from ccai.testbase.properties import strategies
40
+ from ccai.testbase.properties import strategies as st