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:
228228 console .error (f"{ ex } " )
229229 sys .exit (1 )
230230
231+ except FileNotFoundError :
232+ console .error (f"Error: file '{ args .file } ' not found" )
233+ sys .exit (1 )
234+
231235
232236if __name__ == "__main__" :
233237 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(
383383 main ()
384384 assert config .verbose is True
385385
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+
386402
387403class TestCLIMainQuiet :
388404 # main : quiet (directly checking stdout and stderr)
You can’t perform that action at this time.
0 commit comments