@@ -215,10 +215,13 @@ def test_eq_common(self):
215
215
self .assertNotEqual (P (), {})
216
216
self .assertNotEqual (P (), int )
217
217
218
- def test_match_common (self ):
218
+ def test_match_empty (self ):
219
219
P = self .cls
220
220
self .assertRaises (ValueError , P ('a' ).match , '' )
221
221
self .assertRaises (ValueError , P ('a' ).match , '.' )
222
+
223
+ def test_match_common (self ):
224
+ P = self .cls
222
225
# Simple relative pattern.
223
226
self .assertTrue (P ('b.py' ).match ('b.py' ))
224
227
self .assertTrue (P ('a/b.py' ).match ('b.py' ))
@@ -398,14 +401,17 @@ def test_anchor_common(self):
398
401
self .assertEqual (P ('/' ).anchor , sep )
399
402
self .assertEqual (P ('/a/b' ).anchor , sep )
400
403
401
- def test_name_common (self ):
404
+ def test_name_empty (self ):
402
405
P = self .cls
403
406
self .assertEqual (P ('' ).name , '' )
404
407
self .assertEqual (P ('.' ).name , '' )
408
+ self .assertEqual (P ('/a/b/.' ).name , 'b' )
409
+
410
+ def test_name_common (self ):
411
+ P = self .cls
405
412
self .assertEqual (P ('/' ).name , '' )
406
413
self .assertEqual (P ('a/b' ).name , 'b' )
407
414
self .assertEqual (P ('/a/b' ).name , 'b' )
408
- self .assertEqual (P ('/a/b/.' ).name , 'b' )
409
415
self .assertEqual (P ('a/b.py' ).name , 'b.py' )
410
416
self .assertEqual (P ('/a/b.py' ).name , 'b.py' )
411
417
@@ -448,10 +454,13 @@ def test_suffixes_common(self):
448
454
self .assertEqual (P ('a/Some name. Ending with a dot.' ).suffixes , [])
449
455
self .assertEqual (P ('/a/Some name. Ending with a dot.' ).suffixes , [])
450
456
451
- def test_stem_common (self ):
457
+ def test_stem_empty (self ):
452
458
P = self .cls
453
459
self .assertEqual (P ('' ).stem , '' )
454
460
self .assertEqual (P ('.' ).stem , '' )
461
+
462
+ def test_stem_common (self ):
463
+ P = self .cls
455
464
self .assertEqual (P ('..' ).stem , '..' )
456
465
self .assertEqual (P ('/' ).stem , '' )
457
466
self .assertEqual (P ('a/b' ).stem , 'b' )
@@ -470,11 +479,17 @@ def test_with_name_common(self):
470
479
self .assertEqual (P ('/a/b.py' ).with_name ('d.xml' ), P ('/a/d.xml' ))
471
480
self .assertEqual (P ('a/Dot ending.' ).with_name ('d.xml' ), P ('a/d.xml' ))
472
481
self .assertEqual (P ('/a/Dot ending.' ).with_name ('d.xml' ), P ('/a/d.xml' ))
482
+
483
+ def test_with_name_empty (self ):
484
+ P = self .cls
473
485
self .assertRaises (ValueError , P ('' ).with_name , 'd.xml' )
474
486
self .assertRaises (ValueError , P ('.' ).with_name , 'd.xml' )
475
487
self .assertRaises (ValueError , P ('/' ).with_name , 'd.xml' )
476
488
self .assertRaises (ValueError , P ('a/b' ).with_name , '' )
477
489
self .assertRaises (ValueError , P ('a/b' ).with_name , '.' )
490
+
491
+ def test_with_name_seps (self ):
492
+ P = self .cls
478
493
self .assertRaises (ValueError , P ('a/b' ).with_name , '/c' )
479
494
self .assertRaises (ValueError , P ('a/b' ).with_name , 'c/' )
480
495
self .assertRaises (ValueError , P ('a/b' ).with_name , 'c/d' )
@@ -488,11 +503,17 @@ def test_with_stem_common(self):
488
503
self .assertEqual (P ('/a/b.tar.gz' ).with_stem ('d' ), P ('/a/d.gz' ))
489
504
self .assertEqual (P ('a/Dot ending.' ).with_stem ('d' ), P ('a/d' ))
490
505
self .assertEqual (P ('/a/Dot ending.' ).with_stem ('d' ), P ('/a/d' ))
506
+
507
+ def test_with_stem_empty (self ):
508
+ P = self .cls
491
509
self .assertRaises (ValueError , P ('' ).with_stem , 'd' )
492
510
self .assertRaises (ValueError , P ('.' ).with_stem , 'd' )
493
511
self .assertRaises (ValueError , P ('/' ).with_stem , 'd' )
494
512
self .assertRaises (ValueError , P ('a/b' ).with_stem , '' )
495
513
self .assertRaises (ValueError , P ('a/b' ).with_stem , '.' )
514
+
515
+ def test_with_stem_seps (self ):
516
+ P = self .cls
496
517
self .assertRaises (ValueError , P ('a/b' ).with_stem , '/c' )
497
518
self .assertRaises (ValueError , P ('a/b' ).with_stem , 'c/' )
498
519
self .assertRaises (ValueError , P ('a/b' ).with_stem , 'c/d' )
@@ -506,10 +527,16 @@ def test_with_suffix_common(self):
506
527
# Stripping suffix.
507
528
self .assertEqual (P ('a/b.py' ).with_suffix ('' ), P ('a/b' ))
508
529
self .assertEqual (P ('/a/b' ).with_suffix ('' ), P ('/a/b' ))
530
+
531
+ def test_with_suffix_empty (self ):
532
+ P = self .cls
509
533
# Path doesn't have a "filename" component.
510
534
self .assertRaises (ValueError , P ('' ).with_suffix , '.gz' )
511
535
self .assertRaises (ValueError , P ('.' ).with_suffix , '.gz' )
512
536
self .assertRaises (ValueError , P ('/' ).with_suffix , '.gz' )
537
+
538
+ def test_with_suffix_seps (self ):
539
+ P = self .cls
513
540
# Invalid suffix.
514
541
self .assertRaises (ValueError , P ('a/b' ).with_suffix , 'gz' )
515
542
self .assertRaises (ValueError , P ('a/b' ).with_suffix , '/' )
0 commit comments