1+ from __future__ import annotations
2+
13import subprocess
24import sys
35from pathlib import Path
46
57
6- HOOK = Path (__file__ ).parents [1 ] / " pre_commit_hooks" / " forbid_articles_in_test_filenames.py"
8+ HOOK = Path (__file__ ).parents [1 ] / ' pre_commit_hooks' / ' forbid_articles_in_test_filenames.py'
79
810
911def run_hook (repo_path : Path ):
@@ -18,39 +20,39 @@ def run_hook(repo_path: Path):
1820
1921
2022def init_git_repo (tmp_path : Path ):
21- subprocess .run ([" git" , " init" ], cwd = tmp_path , check = True )
22- subprocess .
run ([
" git" , " config" , " user.email" , " [email protected] " ],
cwd = tmp_path ,
check = True )
23- subprocess .run ([" git" , " config" , " user.name" , " Test User" ], cwd = tmp_path , check = True )
23+ subprocess .run ([' git' , ' init' ], cwd = tmp_path , check = True )
24+ subprocess .
run ([
' git' , ' config' , ' user.email' , ' [email protected] ' ],
cwd = tmp_path ,
check = True )
25+ subprocess .run ([' git' , ' config' , ' user.name' , ' Test User' ], cwd = tmp_path , check = True )
2426
2527
2628def git_add_all (tmp_path : Path ):
27- subprocess .run ([" git" , " add" , "." ], cwd = tmp_path , check = True )
29+ subprocess .run ([' git' , ' add' , '.' ], cwd = tmp_path , check = True )
2830
2931
3032def test_fails_on_forbidden_article_in_test_filename (tmp_path : Path ):
3133 init_git_repo (tmp_path )
3234
33- bad_test = tmp_path / " tests_create_an_address.py"
34- bad_test .write_text (" def test_something(): pass\n " )
35+ bad_test = tmp_path / ' tests_create_an_address.py'
36+ bad_test .write_text (' def test_something(): pass\n ' )
3537
3638 git_add_all (tmp_path )
3739
3840 code , output = run_hook (tmp_path )
3941
4042 assert code == 1
41- assert " ERROR: Forbidden article in test filename:" in output
42- assert " tests_create_an_address.py" in output
43+ assert ' ERROR: Forbidden article in test filename:' in output
44+ assert ' tests_create_an_address.py' in output
4345
4446
4547def test_passes_on_valid_test_filename (tmp_path : Path ):
4648 init_git_repo (tmp_path )
4749
48- good_test = tmp_path / " tests_create_address.py"
49- good_test .write_text (" def test_something(): pass\n " )
50+ good_test = tmp_path / ' tests_create_address.py'
51+ good_test .write_text (' def test_something(): pass\n ' )
5052
5153 git_add_all (tmp_path )
5254
5355 code , output = run_hook (tmp_path )
5456
5557 assert code == 0
56- assert output == ""
58+ assert output == ''
0 commit comments