From 3fc4f58328db6ee7f6c9edc99b04dd2cc4d1e6e5 Mon Sep 17 00:00:00 2001 From: Jared Koontz Date: Mon, 31 Mar 2025 17:40:36 -0600 Subject: [PATCH] test: add fixture to new test to make it more obvious what we are testing. --- tests/commands/try_repo_test.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/commands/try_repo_test.py b/tests/commands/try_repo_test.py index 0199c233..2f6ae190 100644 --- a/tests/commands/try_repo_test.py +++ b/tests/commands/try_repo_test.py @@ -100,19 +100,28 @@ def test_try_repo_relative_path(cap_out, tempdir_factory): assert not try_repo(try_repo_opts(relative_repo, hook='bash_hook')) -def test_try_repo_no_commits(cap_out, tempdir_factory): +@pytest.mark.parametrize( + 'has_commits', [ + False, + True, + ], +) +def test_try_repo_no_commits(cap_out, tempdir_factory, has_commits): repo = make_repo( tempdir_factory, 'modified_file_returns_zero_repo', - commits=False, + commits=has_commits, ) with cwd(git_dir(tempdir_factory)): bare_repo = os.path.join(repo, '.git') # previously crashed attempting modification changes - with pytest.raises(FatalError) as e: - try_repo(try_repo_opts(bare_repo, hook='bash_hook')) - assert 'appears to have no commits' in e.value + if not has_commits: + with pytest.raises(FatalError) as e: + try_repo(try_repo_opts(bare_repo, hook='bash_hook')) + assert 'appears to have no commits' in e.value + else: + assert not try_repo(try_repo_opts(bare_repo, hook='bash_hook')) def test_try_repo_bare_repo(cap_out, tempdir_factory):