Skip to content

Commit 43473c4

Browse files
authored
Merge pull request commitizen-tools#563 from commitizen-tools/fix-test-case-datetime-mocking
test(changelog): fix datetime mocking error
2 parents edb32a4 + 836a94a commit 43473c4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/commands/test_changelog_command.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from datetime import datetime
23

34
import pytest
45

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

7980

8081
@pytest.mark.usefixtures("tmp_commitizen_project")
81-
@pytest.mark.freeze_time("2022-03-30")
8282
def test_changelog_replacing_unreleased_using_incremental(
8383
mocker, capsys, changelog_path, file_regression
8484
):
@@ -103,13 +103,14 @@ def test_changelog_replacing_unreleased_using_incremental(
103103
cli.main()
104104

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

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

110112

111113
@pytest.mark.usefixtures("tmp_commitizen_project")
112-
@pytest.mark.freeze_time("2022-03-30")
113114
def test_changelog_is_persisted_using_incremental(
114115
mocker, capsys, changelog_path, file_regression
115116
):
@@ -139,7 +140,9 @@ def test_changelog_is_persisted_using_incremental(
139140
cli.main()
140141

141142
with open(changelog_path, "r") as f:
142-
out = f.read()
143+
out = f.read().replace(
144+
datetime.strftime(datetime.now(), "%Y-%m-%d"), "2022-08-14"
145+
)
143146

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

0 commit comments

Comments
 (0)