Download source/tests/test_null.py from naklitechie/openenv-null-control: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/datasets/naklitechie/openenv-null-control/resolve/main/source/tests/test_null.py
- Command line
-
hf download hf://datasets/naklitechie/openenv-null-control/source/tests/test_null.py
-
curl -L -o test_null.py https://huggingface.co/datasets/naklitechie/openenv-null-control/resolve/main/source/tests/test_null.py
1.23 kB
| """In-process checks: every action ends the episode with the same reward. Run: python -m unittest discover -s tests""" | |
| import sys | |
| import unittest | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) | |
| from models import NullAction # noqa: E402 | |
| from server.environment import REWARD, NullEnvironment # noqa: E402 | |
| class NullEnvTest(unittest.TestCase): | |
| def test_reset_is_not_terminal(self): | |
| obs = NullEnvironment().reset(task_id="null") | |
| self.assertFalse(obs.done) | |
| self.assertLess(len(obs.prompt), 200) | |
| def test_every_action_gives_constant_reward(self): | |
| for payload in ({"answer": "done"}, {}, {"answer": "x", "tool": "calc", "n": 3}, {"answer": 0}, {"answer": None}): | |
| env = NullEnvironment() | |
| env.reset(task_id="null") | |
| obs = env.step(NullAction.model_validate(payload)) | |
| self.assertTrue(obs.done) | |
| self.assertEqual(obs.reward, REWARD) | |
| def test_reward_is_half(self): | |
| self.assertEqual(REWARD, 0.5) | |
| def test_unknown_task_rejected(self): | |
| with self.assertRaises(ValueError): | |
| NullEnvironment().reset(task_id="other") | |
| if __name__ == "__main__": | |
| unittest.main() | |