@@ -537,7 +537,7 @@ def test_enable_path_dict(parser, tmp_cwd):
537537 assert data == cfg ["data" ]
538538 with pytest .raises (ArgumentError ) as ctx :
539539 parser .parse_args (["--data=does-not-exist.yaml" ])
540- ctx .match ("does-not-exist.yaml either not accessible or invalid" )
540+ ctx .match ("Expected a path but does-not-exist.yaml either not accessible or invalid" )
541541
542542
543543def test_enable_path_subclass (parser , tmp_cwd ):
@@ -616,8 +616,10 @@ def test_enable_path_list_path_fr(parser, tmp_cwd, mock_stdin, subtests):
616616 with subtests .test ("paths list nargs='+' path not exist" ):
617617 pytest .raises (ArgumentError , lambda : parser .parse_args (["--lists" , str (list_file4 )]))
618618
619- with subtests .test ("paths list nargs='+' list not exist" ):
620- pytest .raises (ArgumentError , lambda : parser .parse_args (["--lists" , "no-such-file" ]))
619+ with subtests .test ("paths list nargs='+' list not exist" ): # TODO: check error message
620+ with pytest .raises (ArgumentError ) as ctx :
621+ parser .parse_args (["--lists" , "no-such-file" ])
622+ ctx .match ("Expected a path but no-such-file either not accessible or invalid" )
621623
622624
623625def test_enable_path_list_path_fr_default_stdin (parser , tmp_cwd , mock_stdin , subtests ):
@@ -643,6 +645,31 @@ def test_enable_path_list_path_fr_default_stdin(parser, tmp_cwd, mock_stdin, sub
643645 assert all (isinstance (x , Path_fr ) for x in cfg .list )
644646 assert ["file1" , "file2" ] == [str (x ) for x in cfg .list ]
645647
648+ with subtests .test ("help" ):
649+ help_str = get_parser_help (parser )
650+ assert "'[\" PATH1\" ,...]' | LIST_OF_PATHS_FILE | -" in help_str
651+
652+
653+ class ClassListPath :
654+ def __init__ (self , files : list [Path_fr ]):
655+ self .files = files
656+
657+
658+ def test_add_class_list_path (parser , tmp_cwd ):
659+ (tmp_cwd / "file1" ).touch ()
660+ (tmp_cwd / "file2" ).touch ()
661+ list_file1 = tmp_cwd / "files.lst"
662+ list_file1 .write_text ("file1\n file2\n " )
663+
664+ parser .add_class_arguments (ClassListPath , "cls" , sub_configs = True )
665+
666+ cfg = parser .parse_args ([f"--cls.files={ list_file1 } " ])
667+ assert all (isinstance (x , Path_fr ) for x in cfg .cls .files )
668+ assert ["file1" , "file2" ] == [str (x ) for x in cfg .cls .files ]
669+
670+ help_str = get_parser_help (parser )
671+ assert "'[\" PATH1\" ,...]' | LIST_OF_PATHS_FILE | -" in help_str
672+
646673
647674class DataOptionalPath :
648675 def __init__ (self , path : Optional [os .PathLike ] = None ):
0 commit comments