# retoor import unittest.mock from devplacepy.services.correction import correct_text def test_correct_text_prompt_preserves_fenced_code_blocks(): captured = {} def fake_gateway(api_key, system, text, timeout, max_growth_factor): captured["system"] = system captured["text"] = text return ("fake result", {"calls": 1}) with unittest.mock.patch( "devplacepy.services.correction.gateway_complete", fake_gateway ): result, _ = correct_text( "test-key", "Fix spelling", "Some text\n```python\nx = 1\n```\nMore text" ) assert result == "fake result" system = captured["system"] assert ( "Do NOT modify content inside Markdown fenced code blocks" in system ), "System prompt must instruct the model to preserve code blocks" assert ( "Preserve the code block fences, the language identifier" in system ), "System prompt must mention preserving language identifiers" assert ( "Only correct prose outside code blocks" in system ), "System prompt must limit corrections to non-code text" assert ( "triple backticks" in system ), "System prompt must mention triple backticks as the delimiter"