pyflightstream.testing (stable)¶
Generated from the docstrings at build time: every one of the 2 names in the __all__ of pyflightstream.testing has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
Public testing assertions with quantified violation reports.
Pipeline role: cross-cutting support module, after the public testing namespaces of numpy and pandas. User campaigns and this repository's own suites compare two kinds of artifacts, and each gets the matching assertion under the project's golden philosophy split:
- Solver scripts and other deterministic ASCII artifacts compare
exactly: :func:
assert_scripts_equalreports the first differing line and the total count of differing lines, never a fuzzy match. - Numeric records (parsed coefficients, ledger values) compare within
tolerances: :func:
assert_records_closereports how many values were compared, how many violate, and the worst offender, so a failure names the size of the disagreement instead of a bare mismatch.
Failure messages carry statistics because a lone "not equal" hides whether one digit moved in one value or the whole record diverged; the count and the worst offender make the difference visible at the first read.
Advanced¶
pyflightstream.testing.assert_records_close
¶
assert_records_close(
actual: Mapping[str, float],
expected: Mapping[str, float],
*,
rtol: float = 1e-07,
atol: float = 0.0,
label: str = "records",
) -> None
Assert two named numeric records agree within tolerances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actual
|
mapping of str to float
|
Values under test, keyed by quantity name. |
required |
expected
|
mapping of str to float
|
Reference values; the key sets must match exactly. |
required |
rtol
|
float
|
Relative tolerance, applied to the expected magnitude. |
1e-07
|
atol
|
float
|
Absolute tolerance floor, for quantities passing through zero. |
0.0
|
label
|
str
|
Name of the record pair in the failure message (openmdao caller-named message contract). |
'records'
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
Key sets differ, or any value violates
|
Examples:
>>> from pyflightstream.testing import assert_records_close
>>> assert_records_close(
... {"CL": 0.5210004, "CDi": 0.0132},
... {"CL": 0.5210, "CDi": 0.0132},
... rtol=1.0e-5,
... )
pyflightstream.testing.assert_scripts_equal
¶
assert_scripts_equal(
actual: str, expected: str, *, label: str = "script"
) -> None
Assert two ASCII scripts are exactly equal, line by line.
Deterministic ASCII artifacts (solver scripts, goldens) compare exactly by policy; a tolerance would hide an emission change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actual
|
str
|
Script text under test. |
required |
expected
|
str
|
Reference text. |
required |
label
|
str
|
Name of the pair in the failure message. |
'script'
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
Any difference. The message reports the first differing line (number and both texts) and the total count of differing lines; endings-only differences (CRLF, trailing newline) are named as such. |
Examples:
>>> from pyflightstream.testing import assert_scripts_equal
>>> assert_scripts_equal("OPEN a.fsm\\n", "OPEN a.fsm\\n", label="golden")