| 1 | import os |
| 2 | import sys |
| 3 | |
| 4 | import pytest |
| 5 | |
| 6 | |
| 7 | def _test_path(test_dir: str, arg: str) -> str: |
| 8 | if os.path.isabs(arg): |
| 9 | return arg |
| 10 | return os.path.join(test_dir, arg) |
| 11 | |
| 12 | |
| 13 | def main() -> int: |
| 14 | test_dir = os.path.dirname(os.path.abspath(__file__)) |
| 15 | test_paths = [_test_path(test_dir, arg) for arg in sys.argv[1:]] |
| 16 | if not test_paths: |
| 17 | test_paths = [test_dir] |
| 18 | |
| 19 | return pytest.main([ |
| 20 | *test_paths, |
| 21 | f'--rootdir={test_dir}', |
| 22 | ]) |
| 23 | |
| 24 | |
| 25 | if __name__ == '__main__': |
| 26 | sys.exit(main()) |