@@ -249,39 +249,91 @@ def test_match_common(self):
249249 self .assertFalse (P ('/ab.py' ).match ('/a/*.py' ))
250250 self .assertFalse (P ('/a/b/c.py' ).match ('/a/*.py' ))
251251 # Multi-part glob-style pattern.
252- self .assertTrue (P ('a' ).match ('**' ))
253- self .assertTrue (P ('c.py' ).match ('**' ))
254- self .assertTrue (P ('a/b/c.py' ).match ('**' ))
255- self .assertTrue (P ('/a/b/c.py' ).match ('**' ))
256- self .assertTrue (P ('/a/b/c.py' ).match ('/**' ))
257- self .assertTrue (P ('/a/b/c.py' ).match ('/a/**' ))
258- self .assertTrue (P ('/a/b/c.py' ).match ('**/*.py' ))
259- self .assertTrue (P ('/a/b/c.py' ).match ('/**/*.py' ))
252+ self .assertFalse (P ('/a/b/c.py' ).match ('/**/*.py' ))
260253 self .assertTrue (P ('/a/b/c.py' ).match ('/a/**/*.py' ))
261- self .assertTrue (P ('/a/b/c.py' ).match ('/a/b/**/*.py' ))
262- self .assertTrue (P ('/a/b/c.py' ).match ('/**/**/**/**/*.py' ))
263- self .assertFalse (P ('c.py' ).match ('**/a.py' ))
264- self .assertFalse (P ('c.py' ).match ('c/**' ))
265- self .assertFalse (P ('a/b/c.py' ).match ('**/a' ))
266- self .assertFalse (P ('a/b/c.py' ).match ('**/a/b' ))
267- self .assertFalse (P ('a/b/c.py' ).match ('**/a/b/c' ))
268- self .assertFalse (P ('a/b/c.py' ).match ('**/a/b/c.' ))
269- self .assertFalse (P ('a/b/c.py' ).match ('**/a/b/c./**' ))
270- self .assertFalse (P ('a/b/c.py' ).match ('**/a/b/c./**' ))
271- self .assertFalse (P ('a/b/c.py' ).match ('/a/b/c.py/**' ))
272- self .assertFalse (P ('a/b/c.py' ).match ('/**/a/b/c.py' ))
273- self .assertRaises (ValueError , P ('a' ).match , '**a/b/c' )
274- self .assertRaises (ValueError , P ('a' ).match , 'a/b/c**' )
275254 # Case-sensitive flag
276255 self .assertFalse (P ('A.py' ).match ('a.PY' , case_sensitive = True ))
277256 self .assertTrue (P ('A.py' ).match ('a.PY' , case_sensitive = False ))
278257 self .assertFalse (P ('c:/a/B.Py' ).match ('C:/A/*.pY' , case_sensitive = True ))
279258 self .assertTrue (P ('/a/b/c.py' ).match ('/A/*/*.Py' , case_sensitive = False ))
280259 # Matching against empty path
281260 self .assertFalse (P ('' ).match ('*' ))
282- self .assertTrue (P ('' ).match ('**' ))
261+ self .assertFalse (P ('' ).match ('**' ))
283262 self .assertFalse (P ('' ).match ('**/*' ))
284263
264+ def test_full_match_common (self ):
265+ P = self .cls
266+ # Simple relative pattern.
267+ self .assertTrue (P ('b.py' ).full_match ('b.py' ))
268+ self .assertFalse (P ('a/b.py' ).full_match ('b.py' ))
269+ self .assertFalse (P ('/a/b.py' ).full_match ('b.py' ))
270+ self .assertFalse (P ('a.py' ).full_match ('b.py' ))
271+ self .assertFalse (P ('b/py' ).full_match ('b.py' ))
272+ self .assertFalse (P ('/a.py' ).full_match ('b.py' ))
273+ self .assertFalse (P ('b.py/c' ).full_match ('b.py' ))
274+ # Wildcard relative pattern.
275+ self .assertTrue (P ('b.py' ).full_match ('*.py' ))
276+ self .assertFalse (P ('a/b.py' ).full_match ('*.py' ))
277+ self .assertFalse (P ('/a/b.py' ).full_match ('*.py' ))
278+ self .assertFalse (P ('b.pyc' ).full_match ('*.py' ))
279+ self .assertFalse (P ('b./py' ).full_match ('*.py' ))
280+ self .assertFalse (P ('b.py/c' ).full_match ('*.py' ))
281+ # Multi-part relative pattern.
282+ self .assertTrue (P ('ab/c.py' ).full_match ('a*/*.py' ))
283+ self .assertFalse (P ('/d/ab/c.py' ).full_match ('a*/*.py' ))
284+ self .assertFalse (P ('a.py' ).full_match ('a*/*.py' ))
285+ self .assertFalse (P ('/dab/c.py' ).full_match ('a*/*.py' ))
286+ self .assertFalse (P ('ab/c.py/d' ).full_match ('a*/*.py' ))
287+ # Absolute pattern.
288+ self .assertTrue (P ('/b.py' ).full_match ('/*.py' ))
289+ self .assertFalse (P ('b.py' ).full_match ('/*.py' ))
290+ self .assertFalse (P ('a/b.py' ).full_match ('/*.py' ))
291+ self .assertFalse (P ('/a/b.py' ).full_match ('/*.py' ))
292+ # Multi-part absolute pattern.
293+ self .assertTrue (P ('/a/b.py' ).full_match ('/a/*.py' ))
294+ self .assertFalse (P ('/ab.py' ).full_match ('/a/*.py' ))
295+ self .assertFalse (P ('/a/b/c.py' ).full_match ('/a/*.py' ))
296+ # Multi-part glob-style pattern.
297+ self .assertTrue (P ('a' ).full_match ('**' ))
298+ self .assertTrue (P ('c.py' ).full_match ('**' ))
299+ self .assertTrue (P ('a/b/c.py' ).full_match ('**' ))
300+ self .assertTrue (P ('/a/b/c.py' ).full_match ('**' ))
301+ self .assertTrue (P ('/a/b/c.py' ).full_match ('/**' ))
302+ self .assertTrue (P ('/a/b/c.py' ).full_match ('/a/**' ))
303+ self .assertTrue (P ('/a/b/c.py' ).full_match ('**/*.py' ))
304+ self .assertTrue (P ('/a/b/c.py' ).full_match ('/**/*.py' ))
305+ self .assertTrue (P ('/a/b/c.py' ).full_match ('/a/**/*.py' ))
306+ self .assertTrue (P ('/a/b/c.py' ).full_match ('/a/b/**/*.py' ))
307+ self .assertTrue (P ('/a/b/c.py' ).full_match ('/**/**/**/**/*.py' ))
308+ self .assertFalse (P ('c.py' ).full_match ('**/a.py' ))
309+ self .assertFalse (P ('c.py' ).full_match ('c/**' ))
310+ self .assertFalse (P ('a/b/c.py' ).full_match ('**/a' ))
311+ self .assertFalse (P ('a/b/c.py' ).full_match ('**/a/b' ))
312+ self .assertFalse (P ('a/b/c.py' ).full_match ('**/a/b/c' ))
313+ self .assertFalse (P ('a/b/c.py' ).full_match ('**/a/b/c.' ))
314+ self .assertFalse (P ('a/b/c.py' ).full_match ('**/a/b/c./**' ))
315+ self .assertFalse (P ('a/b/c.py' ).full_match ('**/a/b/c./**' ))
316+ self .assertFalse (P ('a/b/c.py' ).full_match ('/a/b/c.py/**' ))
317+ self .assertFalse (P ('a/b/c.py' ).full_match ('/**/a/b/c.py' ))
318+ self .assertRaises (ValueError , P ('a' ).full_match , '**a/b/c' )
319+ self .assertRaises (ValueError , P ('a' ).full_match , 'a/b/c**' )
320+ # Case-sensitive flag
321+ self .assertFalse (P ('A.py' ).full_match ('a.PY' , case_sensitive = True ))
322+ self .assertTrue (P ('A.py' ).full_match ('a.PY' , case_sensitive = False ))
323+ self .assertFalse (P ('c:/a/B.Py' ).full_match ('C:/A/*.pY' , case_sensitive = True ))
324+ self .assertTrue (P ('/a/b/c.py' ).full_match ('/A/*/*.Py' , case_sensitive = False ))
325+ # Matching against empty path
326+ self .assertFalse (P ('' ).full_match ('*' ))
327+ self .assertTrue (P ('' ).full_match ('**' ))
328+ self .assertFalse (P ('' ).full_match ('**/*' ))
329+ # Matching with empty pattern
330+ self .assertTrue (P ('' ).full_match ('' ))
331+ self .assertTrue (P ('.' ).full_match ('.' ))
332+ self .assertFalse (P ('/' ).full_match ('' ))
333+ self .assertFalse (P ('/' ).full_match ('.' ))
334+ self .assertFalse (P ('foo' ).full_match ('' ))
335+ self .assertFalse (P ('foo' ).full_match ('.' ))
336+
285337 def test_parts_common (self ):
286338 # `parts` returns a tuple.
287339 sep = self .sep
0 commit comments