Skip to content

Commit

Permalink
fix some unittest errors
Browse files Browse the repository at this point in the history
  • Loading branch information
waketzheng committed Jan 10, 2025
1 parent 5107b82 commit b3ff97f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
12 changes: 8 additions & 4 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from fast_dev_cli.cli import (
DryRun,
ShellCommandError,
_ensure_bool,
exit_if_run_failed,
get_current_version,
Expand Down Expand Up @@ -61,11 +62,14 @@ def test_utils(capsys):

def test_run_shell():
# current version
stream = StringIO()
write_to_stream = redirect_stdout(stream)
with write_to_stream:
with pytest.raises(ShellCommandError):
get_current_version(True, is_poetry=True)
assert "poetry version -s" in stream.getvalue()
# TODO: add [tool.poetry] to pyproject.toml
# stream = StringIO()
# write_to_stream = redirect_stdout(stream)
# with write_to_stream:
# get_current_version(True, is_poetry=True)
# assert "poetry version -s" in stream.getvalue()

name = "TEST_EXIT_IF_RUN_FAILED"
value = "foo"
Expand Down
1 change: 1 addition & 0 deletions tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def test_get_dev_dependencies(tmp_path: Path):
run_and_echo(f"poetry new {project.name}")
with chdir(project):
with project.joinpath(TOML_FILE).open("a") as f:
f.write('\n[tool.poetry.dependencies]\nsix="*"')
f.write(dev_text)
assert UpgradeDependencies.get_args() == (
[],
Expand Down
6 changes: 5 additions & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import re
from pathlib import Path

import pytest

from fast_dev_cli import __version__
from fast_dev_cli.cli import (
TOML_FILE,
ShellCommandError,
_parse_version,
get_current_version,
read_version_from_file,
Expand All @@ -17,8 +20,9 @@ def test_version(capsys):
version()
assert get_current_version(is_poetry=False) in capsys.readouterr().out
assert get_current_version(is_poetry=False) == __version__
assert get_current_version(is_poetry=True) == ""
assert get_current_version() == __version__
with pytest.raises(ShellCommandError):
get_current_version(is_poetry=True)


def test_read_version(tmp_path: Path, capsys):
Expand Down

0 comments on commit b3ff97f

Please sign in to comment.