File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,10 @@ def main() -> None:
228
228
console .error (f"{ ex } " )
229
229
sys .exit (1 )
230
230
231
+ except FileNotFoundError :
232
+ console .error (f"Error: file '{ args .file } ' not found" )
233
+ sys .exit (1 )
234
+
231
235
232
236
if __name__ == "__main__" :
233
237
main () # pragma: no cover
Original file line number Diff line number Diff line change @@ -383,6 +383,22 @@ def test__main__sets_config_for_verbose(
383
383
main ()
384
384
assert config .verbose is True
385
385
386
+ @patch (
387
+ "commitlint.cli.get_args" ,
388
+ return_value = MagicMock (
389
+ file = "path/to/non_existent_file.txt" , skip_detail = False , quiet = False
390
+ ),
391
+ )
392
+ def test__main__with_missing_file (
393
+ self , _mock_get_args , _mock_output_error , mock_output_success
394
+ ):
395
+ mock_open ().side_effect = FileNotFoundError (
396
+ 2 , "No such file or directory" , "path/to/non_existent_file.txt"
397
+ )
398
+
399
+ with pytest .raises (SystemExit ):
400
+ main ()
401
+
386
402
387
403
class TestCLIMainQuiet :
388
404
# main : quiet (directly checking stdout and stderr)
You can’t perform that action at this time.
0 commit comments