From c5c64c267d74aa1bc48d62501206ce300efc089c Mon Sep 17 00:00:00 2001 From: Juan Altmayer Pizzorno Date: Tue, 27 Feb 2024 11:37:44 -0500 Subject: [PATCH] - adjusted arguments parser to enforce directory arguments being directories; --- src/coverup/coverup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/coverup/coverup.py b/src/coverup/coverup.py index dc10d9b..eb8d4ea 100644 --- a/src/coverup/coverup.py +++ b/src/coverup/coverup.py @@ -24,10 +24,15 @@ def parse_args(args=None): ap.add_argument('source_files', type=Path, nargs='*', help='only process certain source file(s)') - ap.add_argument('--tests-dir', type=Path, required=True, + def Path_dir(value): + path_dir = Path(value) + if not path_dir.is_dir(): raise argparse.ArgumentTypeError("must be a directory") + return path_dir + + ap.add_argument('--tests-dir', type=Path_dir, required=True, help='directory where tests reside') - ap.add_argument('--source-dir', '--source', type=Path, required=True, + ap.add_argument('--source-dir', '--source', type=Path_dir, required=True, help='directory where sources reside') ap.add_argument('--checkpoint', type=Path, @@ -92,7 +97,6 @@ def positive_int(value): return ap.parse_args(args) - def test_file_path(test_seq: int) -> Path: """Returns the Path for a test's file, given its sequence number.""" return args.tests_dir / f"test_{PREFIX}_{test_seq}.py"