@@ -452,6 +452,33 @@ def test_weld_paths(self):
452452 self .assertEqual (ft .weld_paths ('/foo/bar' , '/foo/bar' ), '/foo/bar/' )
453453 self .assertEqual (ft .weld_paths ('/foo' , '/foo/bar/baz' ), '/foo/bar/baz/' )
454454
455+ def test_expand_glob_paths (self ):
456+ """Test expand_glob_paths function."""
457+ for dirname in ['empty_dir' , 'test_dir' ]:
458+ ft .mkdir (os .path .join (self .test_prefix , dirname ), parents = True )
459+ for filename in ['file1.txt' , 'test_dir/file2.txt' , 'test_dir/file3.txt' , 'test_dir2/file4.dat' ]:
460+ ft .write_file (os .path .join (self .test_prefix , filename ), 'gibberish' )
461+
462+ globs = [os .path .join (self .test_prefix , '*.txt' ), os .path .join (self .test_prefix , '*' , '*' )]
463+ expected = [
464+ os .path .join (self .test_prefix , 'file1.txt' ),
465+ os .path .join (self .test_prefix , 'test_dir' , 'file2.txt' ),
466+ os .path .join (self .test_prefix , 'test_dir' , 'file3.txt' ),
467+ os .path .join (self .test_prefix , 'test_dir2' , 'file4.dat' ),
468+ ]
469+ self .assertEqual (ft .expand_glob_paths (globs ), expected )
470+
471+ # passing non-glob patterns is fine too
472+ file2 = os .path .join (self .test_prefix , 'test_dir' , 'file2.txt' )
473+ self .assertEqual (ft .expand_glob_paths ([file2 ]), [file2 ])
474+
475+ # test expanding of '~' into $HOME value
476+ # hard overwrite $HOME in environment (used by os.path.expanduser) so we can reliably test this
477+ new_home = os .path .join (self .test_prefix , 'home' )
478+ ft .mkdir (new_home , parents = True )
479+ ft .write_file (os .path .join (new_home , 'test.txt' ), 'test' )
480+ os .environ ['HOME' ] = new_home
481+ self .assertEqual (ft .expand_glob_paths (['~/*.txt' ]), [os .path .join (new_home , 'test.txt' )])
455482
456483 def test_adjust_permissions (self ):
457484 """Test adjust_permissions"""
0 commit comments