Download testbed/boto__botocore/scripts/ci/run-tests from hc99/FEA-Bench: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/datasets/hc99/FEA-Bench/resolve/main/testbed/boto__botocore/scripts/ci/run-tests
- Command line
-
hf download hf://datasets/hc99/FEA-Bench/testbed/boto__botocore/scripts/ci/run-tests
-
curl -L -o run-tests https://huggingface.co/datasets/hc99/FEA-Bench/resolve/main/testbed/boto__botocore/scripts/ci/run-tests
1.95 kB
| #!/usr/bin/env python | |
| # Don't run tests from the root repo dir. | |
| # We want to ensure we're importing from the installed | |
| # binary package not from the CWD. | |
| import argparse | |
| import os | |
| from contextlib import contextmanager | |
| from subprocess import check_call | |
| _dname = os.path.dirname | |
| REPO_ROOT = _dname(_dname(_dname(os.path.abspath(__file__)))) | |
| PACKAGE = "botocore" | |
| def cd(path): | |
| """Change directory while inside context manager.""" | |
| cwd = os.getcwd() | |
| try: | |
| os.chdir(path) | |
| yield | |
| finally: | |
| os.chdir(cwd) | |
| def run(command): | |
| return check_call(command, shell=True) | |
| def process_args(args): | |
| runner = args.test_runner | |
| test_args = "" | |
| if args.with_xdist: | |
| test_args += "-n auto --dist=loadfile --maxprocesses=4 " | |
| if args.with_cov: | |
| test_args += f"--cov={PACKAGE} --cov-report xml " | |
| dirs = " ".join(args.test_dirs) | |
| return runner, test_args, dirs | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument( | |
| "test_dirs", | |
| default=["unit/", "functional/"], | |
| nargs="*", | |
| help="One or more directories containing tests.", | |
| ) | |
| parser.add_argument( | |
| "-r", | |
| "--test-runner", | |
| default="pytest", | |
| help="Test runner to execute tests. Defaults to pytest.", | |
| ) | |
| parser.add_argument( | |
| "-c", | |
| "--with-cov", | |
| default=False, | |
| action="store_true", | |
| help="Run default test-runner with code coverage enabled.", | |
| ) | |
| parser.add_argument( | |
| "-x", | |
| "--with-xdist", | |
| default=False, | |
| action="store_true", | |
| help="Run default test-runner with parallelization.", | |
| ) | |
| raw_args = parser.parse_args() | |
| test_runner, test_args, test_dirs = process_args(raw_args) | |
| cmd = f"{test_runner} {test_args}{test_dirs}" | |
| print(f"Running {cmd}...") | |
| with cd(os.path.join(REPO_ROOT, "tests")): | |
| run(cmd) | |