Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 07e78bc

Browse files
bearomorphismLee-W
authored andcommitted
test(Init): improve coverage for _ask_tag_format
1 parent 80f2812 commit 07e78bc

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎tests/commands/test_init_command.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,38 @@ def test_pre_commit_exec_failed(
255255
commands.Init(config)()
256256

257257

258+
class TestAskTagFormat:
259+
def test_confirm_v_tag_format(self, mocker: MockFixture, config):
260+
init = commands.Init(config)
261+
mocker.patch("questionary.confirm", return_value=FakeQuestion(True))
262+
263+
result = init._ask_tag_format("v1.0.0")
264+
assert result == r"v$version"
265+
266+
def test_reject_v_tag_format(self, mocker: MockFixture, config):
267+
init = commands.Init(config)
268+
mocker.patch("questionary.confirm", return_value=FakeQuestion(False))
269+
mocker.patch("questionary.text", return_value=FakeQuestion("custom-$version"))
270+
271+
result = init._ask_tag_format("v1.0.0")
272+
assert result == "custom-$version"
273+
274+
def test_non_v_tag_format(self, mocker: MockFixture, config):
275+
init = commands.Init(config)
276+
mocker.patch("questionary.text", return_value=FakeQuestion("custom-$version"))
277+
278+
result = init._ask_tag_format("1.0.0")
279+
assert result == "custom-$version"
280+
281+
def test_empty_input_returns_default(self, mocker: MockFixture, config):
282+
init = commands.Init(config)
283+
mocker.patch("questionary.confirm", return_value=FakeQuestion(False))
284+
mocker.patch("questionary.text", return_value=FakeQuestion(""))
285+
286+
result = init._ask_tag_format("v1.0.0")
287+
assert result == "$version" # This is the default format from DEFAULT_SETTINGS
288+
289+
258290
@skip_below_py_3_10
259291
def test_init_command_shows_description_when_use_help_option(
260292
mocker: MockFixture, capsys, file_regression

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /