from amo.evaluation import evaluate_python TESTS = ''' import unittest from solution import add class TestAdd(unittest.TestCase): def test_add(self): self.assertEqual(add(2, 3), 5) ''' def test_valid_code_passes(): result = evaluate_python("def add(a, b):\n return a + b\n", TESTS) assert result.passed assert 80 <= result.score <= 100 def test_wrong_code_fails_tests(): result = evaluate_python("def add(a, b):\n return a - b\n", TESTS) assert not result.passed def test_blocked_import_is_rejected(): result = evaluate_python("import os\ndef add(a, b):\n return a + b", TESTS) assert not result.policy_ok def test_empty_tests_dont_pass(): result = evaluate_python("def add(a, b): return a + b", "") assert not result.passed def test_unittest_mock_import_is_rejected(): result = evaluate_python("from unittest import mock\ndef add(a, b): return a + b", TESTS) assert not result.policy_ok