Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix initialization when quiet and no script entry #7

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/box/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def query_app_entry(query_txt, opts: List) -> None:

if self._quiet: # all automatic
if options == []: # choose package_name:run and raise warning
app_entry = f"{self.pyproj.name_pkg}:run"
click.echo(f"Warning: No app entry found, using {app_entry}:run.")
self.app_entry = f"{self.pyproj.name_pkg}:run"
click.echo(f"Warning: No app entry found, using {self.app_entry}:run.")
else:
self.app_entry = options[0]
else:
Expand Down
26 changes: 25 additions & 1 deletion tests/cli/test_cli_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,31 @@ def test_initialize_project_app_entry_typed(rye_project_no_box, app_entry):


def test_initialize_project_quiet(rye_project_no_box):
"""Initialize a new project."""
"""Initialize a new project quietly."""
runner = CliRunner()
result = runner.invoke(cli, ["init", "-q"])
assert result.exit_code == 0
assert "Project initialized." not in result.output

# assert it's now a box project
pyproj = PyProjectParser()
assert pyproj.is_box_project


def test_initialize_project_quiet_no_project_script(rye_project_no_box):
"""Initialize a new project quietly with app_entry as the package name."""
with open("pyproject.toml", "r") as f:
toml_data = f.read().split("\n")
# delete the line with scripts and save back out
for it, line in enumerate(toml_data):
if "project.scripts" in line:
idx = it
break
toml_data.pop(idx)
toml_data.pop(idx + 1)
with open("pyproject.toml", "w") as f:
f.write("\n".join(toml_data))

runner = CliRunner()
result = runner.invoke(cli, ["init", "-q"])
assert result.exit_code == 0
Expand Down
Loading