Skip to content
Open
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
236 changes: 117 additions & 119 deletions tests/commands/test_bump_command.py

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions tests/commands/test_changelog_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@


@pytest.fixture
def changelog_jinja_file(tmp_project_root: Path) -> Path:
return tmp_project_root / "changelog.jinja"
def changelog_jinja_file(tmp_commitizen_project: Path) -> Path:
return tmp_commitizen_project / "changelog.jinja"


@pytest.fixture
def changelog_tpl(
tmp_project_root: Path, any_changelog_format: ChangelogFormat
tmp_commitizen_project: Path, any_changelog_format: ChangelogFormat
) -> Path:
return tmp_project_root / any_changelog_format.template
return tmp_commitizen_project / any_changelog_format.template


@pytest.fixture
def changelog_file(
tmp_project_root: Path, any_changelog_format: ChangelogFormat
tmp_commitizen_project: Path, any_changelog_format: ChangelogFormat
) -> Path:
return tmp_project_root / any_changelog_format.default_changelog_file
return tmp_commitizen_project / any_changelog_format.default_changelog_file


@pytest.mark.usefixtures("tmp_commitizen_project")
Expand Down Expand Up @@ -437,7 +437,7 @@ def test_changelog_incremental_newline_separates_new_content_from_old(


def test_changelog_without_revision(tmp_commitizen_project, util: UtilFixture):
tmp_commitizen_project.join("CHANGELOG.md").write(
(tmp_commitizen_project / "CHANGELOG.md").write_text(
"""
# Unreleased

Expand Down Expand Up @@ -1266,7 +1266,7 @@ def test_changelog_template_option_precedence(
changelog_file: Path,
changelog_tpl: Path,
):
project_root = Path(tmp_commitizen_project)
project_root = tmp_commitizen_project
cfg_template = project_root / "changelog.cfg"
cmd_template = project_root / "changelog.cmd"

Expand Down Expand Up @@ -1655,7 +1655,7 @@ def test_changelog_template_incremental_variable(
Test that the changelog template is not rendered when the incremental flag is not set.
Reference: https://github.com/commitizen-tools/commitizen/discussions/1620
"""
project_root = Path(tmp_commitizen_project)
project_root = tmp_commitizen_project
changelog_tpl = project_root / any_changelog_format.template
changelog_tpl.write_text(
dedent("""
Expand Down
14 changes: 8 additions & 6 deletions tests/commands/test_check_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def test_check_conventional_commit_succeeds(
),
],
)
def test_check_no_conventional_commit(commit_msg, config, tmpdir):
tempfile = tmpdir.join("temp_commit_file")
tempfile.write(commit_msg)
def test_check_no_conventional_commit(commit_msg, config, tmp_path):
tempfile = tmp_path / "temp_commit_file"
tempfile.write_text(commit_msg)

with pytest.raises(InvalidCommitMessageError):
commands.Check(config=config, arguments={"commit_msg_file": tempfile})()
Expand All @@ -136,9 +136,11 @@ def test_check_no_conventional_commit(commit_msg, config, tmpdir):
"bump: 0.0.1 -> 1.0.0",
],
)
def test_check_conventional_commit(commit_msg, config, success_mock: MockType, tmpdir):
tempfile = tmpdir.join("temp_commit_file")
tempfile.write(commit_msg)
def test_check_conventional_commit(
commit_msg, config, success_mock: MockType, tmp_path
):
tempfile = tmp_path / "temp_commit_file"
tempfile.write_text(commit_msg)
commands.Check(config=config, arguments={"commit_msg_file": tempfile})()
success_mock.assert_called_once()

Expand Down
13 changes: 6 additions & 7 deletions tests/commands/test_commit_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ def staging_is_clean(mocker: MockFixture, tmp_git_project):
@pytest.fixture
def backup_file(tmp_git_project, monkeypatch):
"""Write backup message so Commit finds it when run from tmp_git_project."""
with tmp_git_project.as_cwd():
path = get_backup_file_path()
path.write_text("backup commit", encoding="utf-8")
monkeypatch.chdir(tmp_git_project)
path = get_backup_file_path()
path.write_text("backup commit", encoding="utf-8")


@pytest.mark.usefixtures("staging_is_clean", "commit_mock", "prompt_mock_feat")
Expand Down Expand Up @@ -263,10 +262,10 @@ def test_commit_when_no_user_answer(config, mocker: MockFixture):
commands.Commit(config, {})()


def test_commit_in_non_git_project(tmpdir, config):
with tmpdir.as_cwd():
with pytest.raises(NotAGitProjectError):
commands.Commit(config, {})
def test_commit_in_non_git_project(tmp_path, monkeypatch, config):
monkeypatch.chdir(tmp_path)
with pytest.raises(NotAGitProjectError):
commands.Commit(config, {})


@pytest.mark.usefixtures("staging_is_clean", "commit_mock", "prompt_mock_feat")
Expand Down
Loading