Spaces:
Runtime error
Runtime error
Download test_evaluation.py from Expanded-Repetition/ammo-card: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/Expanded-Repetition/ammo-card/resolve/main/test_evaluation.py
- Command line
-
hf download hf://spaces/Expanded-Repetition/ammo-card/test_evaluation.py
-
curl -L -o test_evaluation.py https://huggingface.co/spaces/Expanded-Repetition/ammo-card/resolve/main/test_evaluation.py
966 Bytes
| 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 | |