Download testbed/pre-commit__pre-commit/tests/prefix_test.py from hc99/FEA-Bench: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/datasets/hc99/FEA-Bench/resolve/main/testbed/pre-commit__pre-commit/tests/prefix_test.py
- Command line
-
hf download hf://datasets/hc99/FEA-Bench/testbed/pre-commit__pre-commit/tests/prefix_test.py
-
curl -L -o prefix_test.py https://huggingface.co/datasets/hc99/FEA-Bench/resolve/main/testbed/pre-commit__pre-commit/tests/prefix_test.py
1.12 kB
| import os.path | |
| import pytest | |
| from pre_commit.prefix import Prefix | |
| def norm_slash(*args): | |
| return tuple(x.replace('/', os.sep) for x in args) | |
| def test_path(prefix, path_end, expected_output): | |
| instance = Prefix(prefix) | |
| ret = instance.path(path_end) | |
| assert ret == expected_output | |
| def test_path_multiple_args(): | |
| instance = Prefix('foo') | |
| ret = instance.path('bar', 'baz') | |
| assert ret == os.path.join('foo', 'bar', 'baz') | |
| def test_exists(tmpdir): | |
| assert not Prefix(str(tmpdir)).exists('foo') | |
| tmpdir.ensure('foo') | |
| assert Prefix(str(tmpdir)).exists('foo') | |
| def test_star(tmpdir): | |
| for f in ('a.txt', 'b.txt', 'c.py'): | |
| tmpdir.join(f).ensure() | |
| assert set(Prefix(str(tmpdir)).star('.txt')) == {'a.txt', 'b.txt'} | |