Spaces:
Running
Running
Download tests/test_cli.py from pgg-engineering/sincekit: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/pgg-engineering/sincekit/resolve/main/tests/test_cli.py
- Command line
-
hf download hf://spaces/pgg-engineering/sincekit/tests/test_cli.py
-
curl -L -o test_cli.py https://huggingface.co/spaces/pgg-engineering/sincekit/resolve/main/tests/test_cli.py
1.02 kB
| """Check the installed command protocol and its nonzero error exits.""" | |
| import json | |
| import subprocess | |
| import sys | |
| cli = sys.argv[1] | |
| def run(text, capacity="16"): | |
| return subprocess.run([cli, capacity], input=text, text=True, capture_output=True) | |
| result = run("touch 7\ntouch 3\ntouch 7\nerase 3\nplan 0 2 3 4\nplan\nrevision\n") | |
| assert result.returncode == 0, result.stderr | |
| batch, empty, revision = map(json.loads, result.stdout.splitlines()) | |
| assert batch == {"revision": "4", "rows": [[3, "4", True], [7, "3", False]], | |
| "prefix_lengths": [2, 2, 1, 0]} | |
| assert empty == {"revision": "4", "rows": [], "prefix_lengths": []} | |
| assert revision == {"revision": "4"} | |
| for text in ["touch -1", "erase 16", "touch 4294967296", "touch 1 2", | |
| "plan 1", "revision extra", "erase", "hello"]: | |
| failure = run(text) | |
| assert failure.returncode and "line 1" in failure.stderr, (text, failure) | |
| assert run("plan 0", "0").returncode == 0 | |
| assert run("", "1x").returncode | |
| print("CLI checks passed") | |