Download tests/test_source.py from iamrahulreddy/L31H14-plus: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/iamrahulreddy/L31H14-plus/resolve/main/tests/test_source.py
- Command line
-
hf download hf://iamrahulreddy/L31H14-plus/tests/test_source.py
-
curl -L -o test_source.py https://huggingface.co/iamrahulreddy/L31H14-plus/resolve/main/tests/test_source.py
1.13 kB
| from __future__ import annotations | |
| import sys | |
| import unittest | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| if str(ROOT) not in sys.path: | |
| sys.path.insert(0, str(ROOT)) | |
| from mech_workbench.probes.source import parse_source_layers, parse_source_position | |
| class SourceHelperTests(unittest.TestCase): | |
| def test_parse_source_layers_range_and_list(self): | |
| self.assertEqual(parse_source_layers("15-17,20,16"), [15, 16, 17, 20]) | |
| def test_parse_source_layers_rejects_descending_range(self): | |
| with self.assertRaises(ValueError): | |
| parse_source_layers("20-15") | |
| def test_parse_source_position_accepts_all_and_single_positions(self): | |
| self.assertEqual(parse_source_position("sweep"), "sweep") | |
| self.assertEqual(parse_source_position("all"), "all") | |
| self.assertEqual(parse_source_position("LAST"), "last") | |
| self.assertEqual(parse_source_position("-1"), "-1") | |
| def test_parse_source_position_rejects_unknown(self): | |
| with self.assertRaises(ValueError): | |
| parse_source_position("entity") | |
| if __name__ == "__main__": | |
| unittest.main() | |