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