Insert Word equation objects for math output
This commit is contained in:
+10
-1
@@ -13,10 +13,19 @@ def test_load_default_config(tmp_path):
|
||||
|
||||
assert cfg.provider == "ollama"
|
||||
assert cfg.hotkey == "ctrl+alt+a"
|
||||
assert cfg.math_text_format == "unicode"
|
||||
assert cfg.math_text_format == "word_equation"
|
||||
assert "Réponds directement" in cfg.system_prompt
|
||||
|
||||
|
||||
def test_accept_word_equation_format(tmp_path):
|
||||
path = tmp_path / "config.json"
|
||||
path.write_text(json.dumps({"provider": "ollama", "math_text_format": "word_equation"}), encoding="utf-8")
|
||||
|
||||
cfg = load_config(path)
|
||||
|
||||
assert cfg.math_text_format == "word_equation"
|
||||
|
||||
|
||||
def test_timeout_zero_disables_timeout(tmp_path):
|
||||
path = tmp_path / "config.json"
|
||||
path.write_text(json.dumps({"provider": "ollama", "request_timeout_seconds": 0}), encoding="utf-8")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from ai_typewriter.math_format import format_math_text
|
||||
from ai_typewriter.math_format import format_math_text, split_word_equation_segments
|
||||
|
||||
|
||||
def test_plain_mode_keeps_linear_math_literal():
|
||||
@@ -19,6 +19,18 @@ def test_unicode_mode_converts_common_operators():
|
||||
assert result == "∫₀¹ f(x) dx ≤ ∑ₖ₌₁ⁿ aₖ"
|
||||
|
||||
|
||||
def test_word_equation_segments_keep_word_unicodemath_syntax():
|
||||
segments = split_word_equation_segments(r"On pose z_1 = x + iy. Puis \alpha = 2.")
|
||||
|
||||
assert [(segment.kind, segment.value) for segment in segments] == [
|
||||
("text", "On pose "),
|
||||
("equation", "z_1 = x + iy"),
|
||||
("text", ". Puis "),
|
||||
("equation", r"\alpha = 2"),
|
||||
("text", "."),
|
||||
]
|
||||
|
||||
|
||||
def test_invalid_math_text_format_is_rejected():
|
||||
with pytest.raises(ValueError):
|
||||
format_math_text("x_1", "bad")
|
||||
|
||||
Reference in New Issue
Block a user