def test_multiline_code(self):
        """Test format reward with complex multiline code blocks."""
        completion = [
            [
                {
                    "content": "<think>\nHere's the analysis\n</think>\n<answer>\n```python\nclass Solution:\n    def __init__(self):\n        self.value = 42\n        \n    def get_value(self):\n        return self.value\n```\n</answer>"
                }
            ]
        ]
        reward_fn = get_code_format_reward(language="python")
        rewards = reward_fn(completion)
        self.assertEqual(rewards[0], 1.0)
Test format reward with complex multiline code blocks.
tests/test_rewards.py