def test_multiple_code_blocks(self):
        """Test format reward with multiple code blocks in think and answer sections."""
        completion = [
            [
                {
                    "content": "<think>\nHere's an example:\n```python\nx = 1\n```\nNow the solution:\n</think>\n<answer>\n```python\ndef solution():\n    return 42\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 multiple code blocks in think and answer sections.
tests/test_rewards.py