summaryrefslogtreecommitdiffstats
path: root/test/test_python.py
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2026-08-09 15:02:21 +0400
committerEthan Werner <mail@ethanwerner.com>2026-08-09 15:02:21 +0400
commit3d92926a902017e7cf1f5738e99ff62da596ce12 (patch)
tree2b55422c26a48759d56fa91f06df24449e9dfa88 /test/test_python.py
parent07e18043145f3d91c8ea7ec3ad41b3c905585277 (diff)
refactormain
Diffstat (limited to 'test/test_python.py')
-rw-r--r--test/test_python.py52
1 files changed, 28 insertions, 24 deletions
diff --git a/test/test_python.py b/test/test_python.py
index a4aa7e2..cfa983b 100644
--- a/test/test_python.py
+++ b/test/test_python.py
@@ -429,16 +429,21 @@ def parse_test_file(test_path):
params = resolved
if params is None:
- scalar_match = re.search(
+ # Extract ALL scalar variables (not just the first)
+ scalar_matches = re.finditer(
r"(?:uint_t|fp_t|int)\s+(?:const\s+)?(\w+)\s*=\s*([^;]+);", content
)
- if scalar_match:
- var_name = scalar_match.group(1)
- if var_name not in ("n", "offset", "y_n", "i", "j"):
- val_text = scalar_match.group(2).strip()
- result = _safe_float(val_text)
- if result is not None:
- params = {var_name: result}
+ collected = {}
+ for sm in scalar_matches:
+ var_name = sm.group(1)
+ if var_name in ("n", "offset", "y_n", "i", "j"):
+ continue
+ val_text = sm.group(2).strip()
+ result = _safe_float(val_text)
+ if result is not None:
+ collected[var_name] = result
+ if collected:
+ params = collected
return {
"inputs": inputs,
@@ -565,12 +570,6 @@ def _run_tests():
if not parsed:
# Fallback: random inputs + default params from binding signature
rng.seed(SEED)
- rng.jumpahead(rng_offsets.get(fname, 0)) if hasattr(
- rng, "jumpahead"
- ) else None
- for _ in range(x_n * N):
- rng.uniform(0, 100)
- rng.seed(SEED)
if hasattr(rng, "jumpahead"):
rng.jumpahead(rng_offsets.get(fname, 0))
inputs = [[rng.uniform(0, 100) for _ in range(N)] for _ in range(x_n)]
@@ -595,7 +594,7 @@ def _run_tests():
py_params = binding_params
else:
c_params = params
- py_params = None
+ py_params = params
# Call Python binding
func = getattr(ts, fname, None)
@@ -620,16 +619,21 @@ def _run_tests():
else:
py_result = func(*np_inputs)
py_result = normalize_result(py_result, y_n, n)
- except Exception as e:
- err_msg = str(e)
- if (
- re.search(r"ts_\w+\s+error", err_msg)
- and not binding_params
- and c_params
- ):
- skipped += 1
- print(f" SKIP {fname} (binding missing params, C needs them)")
+ except TypeError as e:
+ # Param name mismatch: retry with no params (binding defaults)
+ if py_params:
+ try:
+ py_result = func(*np_inputs)
+ py_result = normalize_result(py_result, y_n, n)
+ except Exception as e2:
+ failed += 1
+ print(f" FAIL {fname}: {e2}")
+ continue
+ else:
+ failed += 1
+ print(f" FAIL {fname}: {e}")
continue
+ except Exception as e:
failed += 1
print(f" FAIL {fname}: {e}")
continue