test: strengthen uppercase canonical test + add _detect_trend boundary cases
Browse files- Assert captured.err == "" in test_subtext_read_uppercase_canonical_coerced to verify no warning is emitted when .lower() hits the canonical directly
- Add test_detect_trend_rising_exactly_3: confirms len==3 is the minimum valid trend
- Add test_detect_trend_run_length_2_returns_none: confirms a tail run of 2 is below threshold
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- tests/test_schemas.py +12 -2
tests/test_schemas.py
CHANGED
|
@@ -653,8 +653,8 @@ def test_subtext_read_unknown_falls_back_to_language_drift(capsys):
|
|
| 653 |
def test_subtext_read_uppercase_canonical_coerced(capsys):
|
| 654 |
s = _str(signal_type="Accounting_Quality")
|
| 655 |
assert s.signal_type == "accounting_quality"
|
| 656 |
-
|
| 657 |
-
|
| 658 |
|
| 659 |
|
| 660 |
def test_subtext_read_evidence_is_sourced_fact():
|
|
@@ -703,6 +703,16 @@ def test_detect_trend_too_short_returns_none():
|
|
| 703 |
assert _detect_trend([1, 3]) is None
|
| 704 |
|
| 705 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 706 |
def test_detect_trend_empty_returns_none():
|
| 707 |
assert _detect_trend([]) is None
|
| 708 |
|
|
|
|
| 653 |
def test_subtext_read_uppercase_canonical_coerced(capsys):
|
| 654 |
s = _str(signal_type="Accounting_Quality")
|
| 655 |
assert s.signal_type == "accounting_quality"
|
| 656 |
+
captured = capsys.readouterr()
|
| 657 |
+
assert captured.err == "" # .lower() hits canonical directly — no coercion warning
|
| 658 |
|
| 659 |
|
| 660 |
def test_subtext_read_evidence_is_sourced_fact():
|
|
|
|
| 703 |
assert _detect_trend([1, 3]) is None
|
| 704 |
|
| 705 |
|
| 706 |
+
def test_detect_trend_rising_exactly_3():
|
| 707 |
+
"""Exactly 3 strictly increasing values — the minimum for a valid trend."""
|
| 708 |
+
assert _detect_trend([1, 2, 3]) == "rising 3 quarters"
|
| 709 |
+
|
| 710 |
+
|
| 711 |
+
def test_detect_trend_run_length_2_returns_none():
|
| 712 |
+
"""Tail run of exactly 2 — below the 3-quarter minimum threshold."""
|
| 713 |
+
assert _detect_trend([1, 2, 1, 2]) is None
|
| 714 |
+
|
| 715 |
+
|
| 716 |
def test_detect_trend_empty_returns_none():
|
| 717 |
assert _detect_trend([]) is None
|
| 718 |
|