1- import  os 
21import  sys 
32from  pathlib  import  Path 
43from  textwrap  import  dedent 
@@ -28,18 +27,19 @@ def test_create_tag(test_input, expected):
2827
2928
3029@pytest .mark .parametrize ("retry" , (True , False )) 
31- def  test_bump_pre_commit_changelog (tmp_commitizen_project , mocker , freezer , retry ):
30+ @pytest .mark .usefixtures ("tmp_commitizen_project" ) 
31+ def  test_bump_pre_commit_changelog (mocker , freezer , retry ):
3232    freezer .move_to ("2022-04-01" )
3333    testargs  =  ["cz" , "bump" , "--changelog" , "--yes" ]
3434    if  retry :
3535        testargs .append ("--retry" )
3636    else :
3737        pytest .xfail ("it will fail because pre-commit will reformat CHANGELOG.md" )
3838    mocker .patch .object (sys , "argv" , testargs )
39-     with   tmp_commitizen_project . as_cwd (): 
40-          # Configure prettier as a  pre-commit hook 
41-         Path ( ".pre-commit-config.yaml" ). write_text (
42-             """ 
39+     # Configure prettier as a pre-commit hook 
40+     Path ( ". pre-commit-config.yaml" ). write_text ( 
41+         dedent (
42+             """\  
4343
4444              - repo: https://github.com/pre-commit/mirrors-prettier 
4545                rev: v2.6.2 
@@ -48,44 +48,43 @@ def test_bump_pre_commit_changelog(tmp_commitizen_project, mocker, freezer, retr
4848                  stages: [commit] 
4949            """ 
5050        )
51-         # Prettier inherits editorconfig 
52-         Path (".editorconfig" ).write_text (
53-             """ 
51+     )
52+     # Prettier inherits editorconfig 
53+     Path (".editorconfig" ).write_text (
54+         dedent (
55+             """\  
5456
5557            indent_size = 4 
5658            """ 
5759        )
58-         cmd .run ("git add -A" )
59-         if  os .name  ==  "nt" :
60-             cmd .run ('git commit -m "fix: _test"' )
61-         else :
62-             cmd .run ("git commit -m 'fix: _test'" )
63-         cmd .run ("pre-commit install" )
64-         cli .main ()
65-         # Pre-commit fixed last line adding extra indent and "\" char 
66-         assert  Path ("CHANGELOG.md" ).read_text () ==  dedent (
67-             """\  
68- 
60+     )
61+     cmd .run ("git add -A" )
62+     cmd .run ('git commit -m "fix: _test"' )
63+     cmd .run ("pre-commit install" )
64+     cli .main ()
65+     # Pre-commit fixed last line adding extra indent and "\" char 
66+     assert  Path ("CHANGELOG.md" ).read_text () ==  dedent (
67+         """\  
68+ 
6969
70-              ### Fix 
70+         ### Fix 
7171
72-              -   \\ _test 
73-              """ 
74-          )
72+         -   \\ _test 
73+         """ 
74+     )
7575
7676
7777@pytest .mark .parametrize ("retry" , (True , False )) 
78- def  test_bump_pre_commit_changelog_fails_always (
79-     tmp_commitizen_project , mocker , freezer , retry 
80- ):
78+ @pytest .mark .usefixtures ("tmp_commitizen_project" ) 
79+ def  test_bump_pre_commit_changelog_fails_always (mocker , freezer , retry ):
8180    freezer .move_to ("2022-04-01" )
8281    testargs  =  ["cz" , "bump" , "--changelog" , "--yes" ]
8382    if  retry :
8483        testargs .append ("--retry" )
8584    mocker .patch .object (sys , "argv" , testargs )
86-     with   tmp_commitizen_project . as_cwd (): 
87-         Path ( ".pre-commit-config.yaml" ). write_text (
88-             """ 
85+     Path ( ".pre-commit-config.yaml" ). write_text ( 
86+         dedent (
87+             """\  
8988
9089              - repo: local 
9190                hooks: 
@@ -96,11 +95,9 @@ def test_bump_pre_commit_changelog_fails_always(
9695                  files: CHANGELOG.md 
9796            """ 
9897        )
99-         cmd .run ("git add -A" )
100-         if  os .name  ==  "nt" :
101-             cmd .run ('git commit -m "feat: forbid changelogs"' )
102-         else :
103-             cmd .run ("git commit -m 'feat: forbid changelogs'" )
104-         cmd .run ("pre-commit install" )
105-         with  pytest .raises (exceptions .BumpCommitFailedError ):
106-             cli .main ()
98+     )
99+     cmd .run ("git add -A" )
100+     cmd .run ('git commit -m "feat: forbid changelogs"' )
101+     cmd .run ("pre-commit install" )
102+     with  pytest .raises (exceptions .BumpCommitFailedError ):
103+         cli .main ()
0 commit comments