77from textwrap import dedent
88from pathlib import Path
99
10- from test .support .script_helper import assert_python_ok
10+ from test .support .script_helper import assert_python_failure , assert_python_ok
1111from test .test_tools import imports_under_tool , skip_if_missing , toolsdir
1212from test .support .os_helper import temp_cwd , temp_dir
1313
@@ -516,8 +516,19 @@ def test_parse_keyword_spec(self):
516516 parse_spec (spec )
517517 self .assertEqual (str (cm .exception ), message )
518518
519+ def test_missing_exclude_file (self ):
520+ """
521+ Test that an error is raised if the exclude file (passed via
522+ --exclude-file) does not exist.
523+ """
524+ _ , _ , stderr = assert_python_failure (self .script ,
525+ '--exclude-file=foo.txt' )
526+ self .assertIn ("Can't read --exclude-file: foo.txt" ,
527+ stderr .decode ('utf-8' ))
528+
519529
520530def extract_from_snapshots ():
531+ exclude_file = DATA_DIR / 'excluded.txt'
521532 snapshots = {
522533 'messages.py' : (),
523534 'fileloc.py' : ('--docstrings' ,),
@@ -526,6 +537,8 @@ def extract_from_snapshots():
526537 'custom_keywords.py' : ('--keyword=foo' , '--keyword=nfoo:1,2' ,
527538 '--keyword=pfoo:1c,2' ,
528539 '--keyword=npfoo:1c,2,3' , '--keyword=_:1,2' ),
540+ # Test excluded msgids with an exclude file
541+ 'excluded.py' : (f'--exclude-file={ exclude_file } ' ,),
529542 }
530543
531544 for filename , args in snapshots .items ():
0 commit comments