@@ -194,8 +194,10 @@ def _setup(self, tmp_path):
194194
195195 def test_empty_repo (self , capsys , repo , make_git_repo ):
196196 git_repo = make_git_repo (repo .location , commit = True )
197- with patch ("sys.argv" , self .args ), pytest .raises (SystemExit ) as excinfo , chdir (
198- git_repo .path
197+ with (
198+ patch ("sys.argv" , self .args ),
199+ pytest .raises (SystemExit ) as excinfo ,
200+ chdir (git_repo .path ),
199201 ):
200202 self .script ()
201203 assert excinfo .value .code == 2
@@ -212,19 +214,24 @@ def test_git_message_opts(self, repo, make_git_repo, tmp_path):
212214 with open (path , "w" ) as f :
213215 f .write ("commit1" )
214216
215- with patch ("sys.argv" , self .args + ["-u" , "-F" , path ]), pytest .raises (
216- SystemExit
217- ) as excinfo , chdir (git_repo .path ):
217+ with (
218+ patch ("sys.argv" , self .args + ["-u" , "-F" , path ]),
219+ pytest .raises (SystemExit ) as excinfo ,
220+ chdir (git_repo .path ),
221+ ):
218222 self .script ()
219223 assert excinfo .value .code == 0
220224 commit_msg = git_repo .log (["-1" , "--pretty=tformat:%B" , "HEAD" ])
221225 assert commit_msg == ["commit1" ]
222226
223227 repo .create_ebuild ("cat/pkg-1" )
224228 git_repo .add_all ("cat/pkg-1" , commit = False )
225- with os_environ (GIT_EDITOR = "sed -i '1s/1/2/'" ), patch (
226- "sys.argv" , self .args + ["-u" , "-t" , path ]
227- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
229+ with (
230+ os_environ (GIT_EDITOR = "sed -i '1s/1/2/'" ),
231+ patch ("sys.argv" , self .args + ["-u" , "-t" , path ]),
232+ pytest .raises (SystemExit ) as excinfo ,
233+ chdir (git_repo .path ),
234+ ):
228235 self .script ()
229236 assert excinfo .value .code == 0
230237 commit_msg = git_repo .log (["-1" , "--pretty=tformat:%B" , "HEAD" ])
@@ -251,9 +258,11 @@ def test_message_template(self, capsys, repo, make_git_repo, tmp_path):
251258 for i , opt in enumerate (["-M" , "--message-template" ], 1 ):
252259 repo .create_ebuild (f"cat/pkg-{ i } " )
253260 git_repo .add_all (f"cat/pkg-{ i } " , commit = False )
254- with patch ("sys.argv" , self .args + ["-u" , opt , path ]), pytest .raises (
255- SystemExit
256- ) as excinfo , chdir (git_repo .path ):
261+ with (
262+ patch ("sys.argv" , self .args + ["-u" , opt , path ]),
263+ pytest .raises (SystemExit ) as excinfo ,
264+ chdir (git_repo .path ),
265+ ):
257266 self .script ()
258267 assert excinfo .value .code == 0
259268 commit_msg = git_repo .log (["-1" , "--pretty=tformat:%B" , "HEAD" ])
@@ -274,9 +283,11 @@ def test_message_template(self, capsys, repo, make_git_repo, tmp_path):
274283 for i , opt in enumerate (["-M" , "--message-template" ], 3 ):
275284 repo .create_ebuild (f"cat/pkg-{ i } " )
276285 git_repo .add_all (f"cat/pkg-{ i } " , commit = False )
277- with patch ("sys.argv" , self .args + ["-u" , opt , path ]), pytest .raises (
278- SystemExit
279- ) as excinfo , chdir (git_repo .path ):
286+ with (
287+ patch ("sys.argv" , self .args + ["-u" , opt , path ]),
288+ pytest .raises (SystemExit ) as excinfo ,
289+ chdir (git_repo .path ),
290+ ):
280291 self .script ()
281292 assert excinfo .value .code == 0
282293 commit_msg = git_repo .log (["-1" , "--pretty=tformat:%B" , "HEAD" ])
@@ -289,9 +300,11 @@ def test_message_template(self, capsys, repo, make_git_repo, tmp_path):
289300 for i , opt in enumerate (["-M" , "--message-template" ], 5 ):
290301 repo .create_ebuild (f"cat/pkg-{ i } " )
291302 git_repo .add_all (f"cat/pkg-{ i } " , commit = False )
292- with patch ("sys.argv" , self .args + ["-u" , opt , path ]), pytest .raises (
293- SystemExit
294- ) as excinfo , chdir (git_repo .path ):
303+ with (
304+ patch ("sys.argv" , self .args + ["-u" , opt , path ]),
305+ pytest .raises (SystemExit ) as excinfo ,
306+ chdir (git_repo .path ),
307+ ):
295308 self .script ()
296309 assert excinfo .value .code == 2
297310 out , err = capsys .readouterr ()
@@ -305,9 +318,11 @@ def test_custom_unprefixed_message(self, capsys, repo, make_git_repo):
305318 with open (ebuild_path , "a+" ) as f :
306319 f .write ("# comment\n " )
307320
308- with patch ("sys.argv" , self .args + ["-u" , "-m" , "msg" ]), pytest .raises (
309- SystemExit
310- ) as excinfo , chdir (git_repo .path ):
321+ with (
322+ patch ("sys.argv" , self .args + ["-u" , "-m" , "msg" ]),
323+ pytest .raises (SystemExit ) as excinfo ,
324+ chdir (git_repo .path ),
325+ ):
311326 self .script ()
312327 assert excinfo .value .code == 0
313328 out , err = capsys .readouterr ()
@@ -323,9 +338,11 @@ def test_custom_prefixed_message(self, capsys, repo, make_git_repo):
323338 with open (ebuild_path , "a+" ) as f :
324339 f .write ("# comment\n " )
325340
326- with patch ("sys.argv" , self .args + ["-u" , "-m" , "prefix: msg" ]), pytest .raises (
327- SystemExit
328- ) as excinfo , chdir (git_repo .path ):
341+ with (
342+ patch ("sys.argv" , self .args + ["-u" , "-m" , "prefix: msg" ]),
343+ pytest .raises (SystemExit ) as excinfo ,
344+ chdir (git_repo .path ),
345+ ):
329346 self .script ()
330347 assert excinfo .value .code == 0
331348 out , err = capsys .readouterr ()
@@ -341,9 +358,12 @@ def test_edited_commit_message(self, capsys, repo, make_git_repo):
341358 with open (ebuild_path , "a+" ) as f :
342359 f .write ("# comment\n " )
343360
344- with os_environ (GIT_EDITOR = "sed -i '1s/$/commit/'" ), patch (
345- "sys.argv" , self .args + ["-u" ]
346- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
361+ with (
362+ os_environ (GIT_EDITOR = "sed -i '1s/$/commit/'" ),
363+ patch ("sys.argv" , self .args + ["-u" ]),
364+ pytest .raises (SystemExit ) as excinfo ,
365+ chdir (git_repo .path ),
366+ ):
347367 self .script ()
348368 assert excinfo .value .code == 0
349369 out , err = capsys .readouterr ()
@@ -358,9 +378,11 @@ def test_generated_commit_prefixes(self, capsys, repo, make_git_repo):
358378 git_repo .add_all ("cat/pkg-0" )
359379
360380 def commit ():
361- with patch ("sys.argv" , self .args + ["-a" , "-m" , "msg" ]), pytest .raises (
362- SystemExit
363- ) as excinfo , chdir (git_repo .path ):
381+ with (
382+ patch ("sys.argv" , self .args + ["-a" , "-m" , "msg" ]),
383+ pytest .raises (SystemExit ) as excinfo ,
384+ chdir (git_repo .path ),
385+ ):
364386 self .script ()
365387 assert excinfo .value .code == 0
366388 out , err = capsys .readouterr ()
@@ -441,9 +463,12 @@ def test_generated_commit_summaries(self, capsys, repo, make_git_repo):
441463 git_repo .add_all ("cat/pkg-0" )
442464
443465 def commit ():
444- with os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ), patch (
445- "sys.argv" , self .args + ["-a" ]
446- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
466+ with (
467+ os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ),
468+ patch ("sys.argv" , self .args + ["-a" ]),
469+ pytest .raises (SystemExit ) as excinfo ,
470+ chdir (git_repo .path ),
471+ ):
447472 self .script ()
448473 assert excinfo .value .code == 0
449474 out , err = capsys .readouterr ()
@@ -592,9 +617,12 @@ def test_generated_commit_summaries_keywords(self, capsys, make_repo, make_git_r
592617 git_repo .add_all ("cat/pkg-0" )
593618
594619 def commit ():
595- with os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ), patch (
596- "sys.argv" , self .args + ["-a" ]
597- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
620+ with (
621+ os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ),
622+ patch ("sys.argv" , self .args + ["-a" ]),
623+ pytest .raises (SystemExit ) as excinfo ,
624+ chdir (git_repo .path ),
625+ ):
598626 self .script ()
599627 assert excinfo .value .code == 0
600628 out , err = capsys .readouterr ()
@@ -670,9 +698,12 @@ def test_metadata_summaries(self, capsys, repo, make_git_repo):
670698 git_repo .add_all ("cat/pkg-0" )
671699
672700 def commit ():
673- with os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ), patch (
674- "sys.argv" , self .args + ["-a" ]
675- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
701+ with (
702+ os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ),
703+ patch ("sys.argv" , self .args + ["-a" ]),
704+ pytest .raises (SystemExit ) as excinfo ,
705+ chdir (git_repo .path ),
706+ ):
676707 self .script ()
677708 assert excinfo .value .code == 0
678709 out , err = capsys .readouterr ()
@@ -859,9 +890,12 @@ def test_no_summary(self, capsys, repo, make_git_repo):
859890 git_repo .add_all ("cat/pkg-0" )
860891
861892 def commit (args ):
862- with os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ), patch (
863- "sys.argv" , self .args + args
864- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
893+ with (
894+ os_environ (GIT_EDITOR = "sed -i '1s/$/summary/'" ),
895+ patch ("sys.argv" , self .args + args ),
896+ pytest .raises (SystemExit ) as excinfo ,
897+ chdir (git_repo .path ),
898+ ):
865899 self .script ()
866900 assert excinfo .value .code == 0
867901 out , err = capsys .readouterr ()
@@ -886,8 +920,10 @@ def test_non_gentoo_file_mangling(self, repo, make_git_repo):
886920 git_repo .add_all ("cat/pkg-0" )
887921
888922 def commit (args ):
889- with patch ("sys.argv" , self .args + args ), pytest .raises (SystemExit ) as excinfo , chdir (
890- git_repo .path
923+ with (
924+ patch ("sys.argv" , self .args + args ),
925+ pytest .raises (SystemExit ) as excinfo ,
926+ chdir (git_repo .path ),
891927 ):
892928 self .script ()
893929 assert excinfo .value .code == 0
@@ -928,8 +964,10 @@ def test_gentoo_file_mangling(self, make_repo, make_git_repo):
928964 git_repo .add_all ("cat/pkg-0" )
929965
930966 def commit (args ):
931- with patch ("sys.argv" , self .args + args ), pytest .raises (SystemExit ) as excinfo , chdir (
932- git_repo .path
967+ with (
968+ patch ("sys.argv" , self .args + args ),
969+ pytest .raises (SystemExit ) as excinfo ,
970+ chdir (git_repo .path ),
933971 ):
934972 self .script ()
935973 assert excinfo .value .code == 0
@@ -1006,8 +1044,10 @@ def test_scan(self, capsys, repo, make_git_repo):
10061044 for i , opt in enumerate (["-s" , "--scan" ], 1 ):
10071045 repo .create_ebuild (f"cat/pkg-{ i } " )
10081046 git_repo .add_all (f"cat/pkg-{ i } " , commit = False )
1009- with patch ("sys.argv" , self .args + [opt ]), pytest .raises (SystemExit ) as excinfo , chdir (
1010- git_repo .path
1047+ with (
1048+ patch ("sys.argv" , self .args + [opt ]),
1049+ pytest .raises (SystemExit ) as excinfo ,
1050+ chdir (git_repo .path ),
10111051 ):
10121052 self .script ()
10131053 assert excinfo .value .code == 0
@@ -1024,8 +1064,10 @@ def test_failed_scan(self, capsys, repo, make_git_repo):
10241064 # verify staged changes via `pkgcheck scan` before creating commit
10251065 repo .create_ebuild ("cat/pkg-1" , license = "" )
10261066 git_repo .add_all ("cat/pkg-1" , commit = False )
1027- with patch ("sys.argv" , self .args + ["--scan" ]), pytest .raises (SystemExit ) as excinfo , chdir (
1028- git_repo .path
1067+ with (
1068+ patch ("sys.argv" , self .args + ["--scan" ]),
1069+ pytest .raises (SystemExit ) as excinfo ,
1070+ chdir (git_repo .path ),
10291071 ):
10301072 self .script ()
10311073 assert excinfo .value .code == 1
@@ -1043,9 +1085,12 @@ def test_failed_scan(self, capsys, repo, make_git_repo):
10431085 )
10441086
10451087 # ignore failures to create the commit
1046- with patch ("sys.argv" , self .args + ["--scan" , "--ask" ]), patch (
1047- "sys.stdin" , StringIO ("y\n " )
1048- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
1088+ with (
1089+ patch ("sys.argv" , self .args + ["--scan" , "--ask" ]),
1090+ patch ("sys.stdin" , StringIO ("y\n " )),
1091+ pytest .raises (SystemExit ) as excinfo ,
1092+ chdir (git_repo .path ),
1093+ ):
10491094 self .script ()
10501095 assert excinfo .value .code == 0
10511096
@@ -1066,9 +1111,11 @@ def test_config_opts(self, capsys, repo, make_git_repo, tmp_path):
10661111 git_repo .add_all ("cat/pkg-0" )
10671112 repo .create_ebuild ("cat/pkg-1" , license = "" )
10681113 git_repo .add_all ("cat/pkg-1" , commit = False )
1069- with patch (
1070- "sys.argv" , ["pkgdev" , "commit" , "--config" , config_file ] + self .scan_args
1071- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
1114+ with (
1115+ patch ("sys.argv" , ["pkgdev" , "commit" , "--config" , config_file ] + self .scan_args ),
1116+ pytest .raises (SystemExit ) as excinfo ,
1117+ chdir (git_repo .path ),
1118+ ):
10721119 self .script ()
10731120 out , err = capsys .readouterr ()
10741121 assert excinfo .value .code == 1
@@ -1092,9 +1139,11 @@ def test_config_repo_opts(self, capsys, repo, make_git_repo, tmp_path):
10921139 git_repo .add_all ("cat/pkg-0" )
10931140 repo .create_ebuild ("cat/pkg-1" , license = "" )
10941141 git_repo .add_all ("cat/pkg-1" , commit = False )
1095- with patch (
1096- "sys.argv" , ["pkgdev" , "commit" , "--config" , config_file ] + self .scan_args
1097- ), pytest .raises (SystemExit ) as excinfo , chdir (git_repo .path ):
1142+ with (
1143+ patch ("sys.argv" , ["pkgdev" , "commit" , "--config" , config_file ] + self .scan_args ),
1144+ pytest .raises (SystemExit ) as excinfo ,
1145+ chdir (git_repo .path ),
1146+ ):
10981147 self .script ()
10991148 out , err = capsys .readouterr ()
11001149 assert excinfo .value .code == 1
@@ -1107,8 +1156,10 @@ def test_failed_manifest(self, capsys, repo, make_git_repo):
11071156 git_repo .add_all ("cat/pkg-0" )
11081157 repo .create_ebuild ("cat/pkg-1" , eapi = "-1" )
11091158 git_repo .add_all ("cat/pkg-1" , commit = False )
1110- with patch ("sys.argv" , self .args ), pytest .raises (SystemExit ) as excinfo , chdir (
1111- git_repo .path
1159+ with (
1160+ patch ("sys.argv" , self .args ),
1161+ pytest .raises (SystemExit ) as excinfo ,
1162+ chdir (git_repo .path ),
11121163 ):
11131164 self .script ()
11141165 assert excinfo .value .code == 1
0 commit comments