@@ -35,6 +35,31 @@ def test_wildcard(self):
3535 self .assertTrue (wildcard .match ("**.jpg" , "foo/a.jpg" ))
3636 self .assertTrue (wildcard .match ("**" , "foo/a.jpg" ))
3737
38+ def test_wildcard_accept_prefix (self ):
39+ self .assertTrue (wildcard .match ("*.py" , "file" , accept_prefix = True ))
40+ self .assertTrue (wildcard .match ("????.py" , "????" , accept_prefix = True ))
41+ self .assertTrue (wildcard .match ("file.py" , "file.p" , accept_prefix = True ))
42+ self .assertTrue (wildcard .match ("file.py[co]" , "file.p" , accept_prefix = True ))
43+ self .assertTrue (wildcard .match ("file.py[co]" , "file.p" , accept_prefix = True ))
44+ self .assertTrue (wildcard .match ("file.py[!c]" , "file.py" , accept_prefix = True ))
45+ self .assertTrue (wildcard .match ("file.py[^]" , "file.py^" , accept_prefix = True ))
46+
47+ self .assertTrue (wildcard .match ("*.jpg" , "file.py" , accept_prefix = True ))
48+ self .assertFalse (wildcard .match ("toolong.py" , "????.py" , accept_prefix = True ))
49+ self .assertFalse (wildcard .match ("file.pyc" , "file.pyca" , accept_prefix = True ))
50+ self .assertFalse (wildcard .match ("file.py[co]" , "file.pyx" , accept_prefix = True ))
51+ self .assertFalse (wildcard .match ("file.py[!o]" , "file.pyo" , accept_prefix = True ))
52+ self .assertTrue (wildcard .match ("file.py[]" , "f" , accept_prefix = True ))
53+
54+ self .assertTrue (wildcard .imatch ("*.py" , "FILE.p" , accept_prefix = True ))
55+ self .assertTrue (wildcard .imatch ("*.py" , "file." , accept_prefix = True ))
56+
57+ self .assertFalse (wildcard .match ("foo*.jpg" , "foo/" , accept_prefix = True ))
58+ self .assertTrue (wildcard .match ("foo**.jpg" , "foo" , accept_prefix = True ))
59+ self .assertTrue (wildcard .match ("foo**" , "foo/" , accept_prefix = True ))
60+ self .assertTrue (wildcard .match ("**.jpg" , "foo" , accept_prefix = True ))
61+ self .assertTrue (wildcard .match ("**" , "foo/a.j" , accept_prefix = True ))
62+
3863 def test_match_any (self ):
3964 self .assertTrue (wildcard .match_any ([], "foo.py" ))
4065 self .assertTrue (wildcard .imatch_any ([], "foo.py" ))
0 commit comments