Download tests/test_state.py from devildasdf/devils-agent: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/devildasdf/devils-agent/resolve/main/tests/test_state.py
- Command line
-
hf download hf://devildasdf/devils-agent/tests/test_state.py
-
curl -L -o test_state.py https://huggingface.co/devildasdf/devils-agent/resolve/main/tests/test_state.py
1.04 kB
| import unittest | |
| from baim.state import Element, State | |
| class StateTests(unittest.TestCase): | |
| def test_hash_excludes_ephemeral_references(self): | |
| a = State("a", 1, "https://example.org", (Element("e1", "button", " Next ", "0"),)) | |
| b = State("b", 7, a.origin, (Element("e9", "button", "Next", "0"),)) | |
| self.assertEqual(a.state_hash, b.state_hash) | |
| self.assertIn("reset", b.delta(a)) | |
| def test_sensitive_name_never_serialized(self): | |
| a = State("a", 1, "https://example.org", (Element("e1", "textbox", "secret", "0", sensitive=True),)) | |
| self.assertNotIn("secret", str(a.compact())) | |
| def test_order_changes_hash(self): | |
| elements = (Element("e1", "link", "A", "0"), Element("e2", "link", "B", "1")) | |
| a = State("a", 1, "https://example.org", elements) | |
| b = State("a", 2, a.origin, tuple(reversed(elements))) | |
| self.assertNotEqual(a.state_hash, b.state_hash) | |
| self.assertEqual(b.delta(a)["order"], ["e2", "e1"]) | |
| if __name__ == "__main__": | |
| unittest.main() | |