Skip to content

test(changelog): fix datetime mocking error #563

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

Merged
merged 1 commit into from
Aug 21, 2022
Merged
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
11 changes: 7 additions & 4 deletions tests/commands/test_changelog_command.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from datetime import datetime

import pytest

Expand Down Expand Up @@ -78,7 +79,6 @@ def test_changelog_from_start(mocker, capsys, changelog_path, file_regression):


@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-03-30")
def test_changelog_replacing_unreleased_using_incremental(
mocker, capsys, changelog_path, file_regression
):
Expand All @@ -103,13 +103,14 @@ def test_changelog_replacing_unreleased_using_incremental(
cli.main()

with open(changelog_path, "r") as f:
out = f.read()
out = f.read().replace(
datetime.strftime(datetime.now(), "%Y-%m-%d"), "2022-08-14"
)

file_regression.check(out, extension=".md")


@pytest.mark.usefixtures("tmp_commitizen_project")
@pytest.mark.freeze_time("2022-03-30")
def test_changelog_is_persisted_using_incremental(
mocker, capsys, changelog_path, file_regression
):
Expand Down Expand Up @@ -139,7 +140,9 @@ def test_changelog_is_persisted_using_incremental(
cli.main()

with open(changelog_path, "r") as f:
out = f.read()
out = f.read().replace(
datetime.strftime(datetime.now(), "%Y-%m-%d"), "2022-08-14"
)

file_regression.check(out, extension=".md")

Expand Down