MCPcopy Create free account
hub / github.com/cxcscmu/AutoGEO / test_correct_python_format

Method test_correct_python_format

open-r1/tests/test_rewards.py:486–497  ·  view source on GitHub ↗

Test code format reward with correct Python format.

(self)

Source from the content-addressed store, hash-verified

484
485class TestCodeFormat(unittest.TestCase):
486 def test_correct_python_format(self):
487 """Test code format reward with correct Python format."""
488 completion = [
489 [
490 {
491 "content": "<think>\nLet's solve this\nStep 1: First step\n</think>\n<answer>\n```python\ndef hello():\n print('world')\n```\n</answer>"
492 }
493 ]
494 ]
495 reward_fn = get_code_format_reward(language="python")
496 rewards = reward_fn(completion)
497 self.assertEqual(rewards[0], 1.0)
498
499 def test_incorrect_formats(self):
500 """Test code format reward with various incorrect formats."""

Callers

nothing calls this directly

Calls 1

get_code_format_rewardFunction · 0.90

Tested by

no test coverage detected