Skip to content

Commit

Permalink
ADD CLI option for --install-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mknorps committed Jul 28, 2023
1 parent da47cba commit f7f4267
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
9 changes: 9 additions & 0 deletions fawltydeps/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ def populate_parser_paths_options(parser: argparse._ActionsContainer) -> None:
" Python environment where FawltyDeps is installed."
),
)
parser.add_argument(
"--install-deps",
dest="install_deps",
action="store_true",
help=(
"Allow FawltyDeps to `pip install` declared dependencies into a"
" separate temporary virtualenv to discover the imports they expose."
),
)
parser.add_argument(
"--custom-mapping-file",
nargs="+",
Expand Down
24 changes: 24 additions & 0 deletions tests/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,30 @@ def test_cmdline_on_ignored_undeclared_option(
).splitlines(),
id="generate_toml_config_with_multiple_pyenvs",
),
pytest.param(
{},
["--install-deps", "--generate-toml-config"],
dedent(
"""\
# Copy this TOML section into your pyproject.toml to configure FawltyDeps
# (default values are commented)
[tool.fawltydeps]
# actions = ['check_undeclared', 'check_unused']
# output_format = 'human_summary'
# code = ['.']
# deps = ['.']
# pyenvs = []
# custom_mapping_file = []
# ignore_undeclared = []
# ignore_unused = []
# deps_parser_choice = ...
install_deps = true
# verbosity = 0
# [tool.fawltydeps.custom_mapping]
"""
).splitlines(),
id="generate_toml_config_with_install_deps",
),
],
)
def test_cmdline_args_in_combination_with_config_file(
Expand Down
4 changes: 3 additions & 1 deletion tests/test_cmdline_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"""
)
venvs = [str(project_with_no_issues / ".venv")]
other = ["--generate-toml-file", "--version"]
other = ["--generate-toml-file", "--version", "--install-deps"]


# Options below contain paths specific for an input project
Expand All @@ -87,6 +87,7 @@ def available_deps_values(project_dir: Path) -> List[str]:
output_formats_strategy = st.lists(
st.sampled_from(output_formats), min_size=0, max_size=1
)
others_strategy = st.lists(st.sampled_from(other), min_size=0, max_size=1)


def code_option_strategy(paths: List[str]):
Expand Down Expand Up @@ -167,6 +168,7 @@ def cli_arguments_combinations(draw):
deps_parser,
draw(verbosity_strategy),
draw(venv_strategy),
draw(others_strategy),
]
)
args = reduce(lambda x, y: x + y, draw(strategy))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
code={Path(".")},
deps={Path(".")},
pyenvs=set(),
custom_mapping_file=set(),
custom_mapping=None,
output_format=OutputFormat.HUMAN_SUMMARY,
ignore_undeclared=set(),
ignore_unused=set(),
deps_parser_choice=None,
install_deps=False,
verbosity=0,
custom_mapping_file=set(),
)


Expand Down

0 comments on commit f7f4267

Please sign in to comment.