Build the full argument parser tree for testing argparse dispatch.
(monkeypatch, api)
| 44 | |
| 45 | @pytest.fixture |
| 46 | def parser(monkeypatch, api): |
| 47 | """Build the full argument parser tree for testing argparse dispatch.""" |
| 48 | import kaggle |
| 49 | |
| 50 | monkeypatch.setattr(kaggle, "api", api) |
| 51 | |
| 52 | from kaggle.cli import ( |
| 53 | Help, |
| 54 | parse_benchmarks, |
| 55 | parse_competitions, |
| 56 | parse_datasets, |
| 57 | parse_forums, |
| 58 | parse_kernels, |
| 59 | parse_models, |
| 60 | ) |
| 61 | import kaggle.cli |
| 62 | |
| 63 | monkeypatch.setattr(kaggle.cli, "api", api) |
| 64 | |
| 65 | root = argparse.ArgumentParser() |
| 66 | root.add_argument("-W", "--no-warn", dest="disable_version_warning", action="store_true") |
| 67 | subparsers = root.add_subparsers(title="commands", dest="command") |
| 68 | subparsers.required = True |
| 69 | subparsers.choices = Help.kaggle_choices |
| 70 | |
| 71 | parse_competitions(subparsers) |
| 72 | parse_datasets(subparsers) |
| 73 | parse_kernels(subparsers) |
| 74 | parse_models(subparsers) |
| 75 | parse_benchmarks(subparsers) |
| 76 | parse_forums(subparsers) |
| 77 | return root |
| 78 | |
| 79 | |
| 80 | def _dispatch(parser, argv): |
nothing calls this directly
no test coverage detected