55from pre_commit_hooks .no_commit_to_branch import is_on_branch
66from pre_commit_hooks .no_commit_to_branch import main
77from pre_commit_hooks .util import cmd_output
8+ from testing .util import get_default_branch
89from testing .util import git_commit
910
1011
12+ default_branch = get_default_branch ()
13+
14+
1115def test_other_branch (temp_git_dir ):
1216 with temp_git_dir .as_cwd ():
1317 cmd_output ('git' , 'checkout' , '-b' , 'anotherbranch' )
14- assert is_on_branch ({'master' }) is False
18+ assert is_on_branch ({default_branch }) is False
1519
1620
1721def test_multi_branch (temp_git_dir ):
1822 with temp_git_dir .as_cwd ():
1923 cmd_output ('git' , 'checkout' , '-b' , 'another/branch' )
20- assert is_on_branch ({'master' }) is False
24+ assert is_on_branch ({default_branch }) is False
2125
2226
2327def test_multi_branch_fail (temp_git_dir ):
@@ -28,7 +32,7 @@ def test_multi_branch_fail(temp_git_dir):
2832
2933def test_master_branch (temp_git_dir ):
3034 with temp_git_dir .as_cwd ():
31- assert is_on_branch ({'master' }) is True
35+ assert is_on_branch ({default_branch }) is True
3236
3337
3438def test_main_branch_call (temp_git_dir ):
@@ -50,11 +54,11 @@ def test_branch_pattern_fail(temp_git_dir):
5054 assert is_on_branch (set (), {'another/.*' }) is True
5155
5256
53- @pytest .mark .parametrize ('branch_name' , ('master' , 'another/branch' ))
57+ @pytest .mark .parametrize ('branch_name' , (default_branch , 'another/branch' ))
5458def test_branch_pattern_multiple_branches_fail (temp_git_dir , branch_name ):
5559 with temp_git_dir .as_cwd ():
5660 cmd_output ('git' , 'checkout' , '-b' , branch_name )
57- assert main (('--branch' , 'master' , '--pattern' , 'another/.*' ))
61+ assert main (('--branch' , default_branch , '--pattern' , 'another/.*' ))
5862
5963
6064def test_main_default_call (temp_git_dir ):
0 commit comments