@@ -411,6 +411,61 @@ def test_list(self, no_color=True):
411
411
],
412
412
)
413
413
414
+ def test_hyphen_list (self , no_color = True ):
415
+ if no_color :
416
+ command = ("routine" , "--no-color" , "test-hyphen" )
417
+ else :
418
+ command = ("routine" , "--force-color" , "test-hyphen" )
419
+
420
+ out = StringIO ()
421
+ call_command (* command , "--all" , "list" , stdout = out )
422
+ plan = self .lines (out .getvalue (), no_color = no_color )
423
+ self .assertEqual (
424
+ plan ,
425
+ [
426
+ "[0] track 1 | hyphen-ok, hyphen-ok-prefix" ,
427
+ "[0] track 2" ,
428
+ "[0] track 3 | hyphen-ok" ,
429
+ "[0] track 4" ,
430
+ "[0] track 5 | hyphen-ok, hyphen-ok-prefix" ,
431
+ ],
432
+ )
433
+
434
+ out = StringIO ()
435
+ call_command (* command , "list" , stdout = out )
436
+ plan = self .lines (out .getvalue (), no_color = no_color )
437
+ self .assertEqual (
438
+ plan ,
439
+ ["[0] track 2" , "[0] track 4" ],
440
+ )
441
+
442
+ out = StringIO ()
443
+ call_command (* command , "--hyphen-ok" , "list" , stdout = out )
444
+ plan = self .lines (out .getvalue (), no_color = no_color )
445
+ self .assertEqual (
446
+ plan ,
447
+ [
448
+ "[0] track 1 | hyphen-ok, hyphen-ok-prefix" ,
449
+ "[0] track 2" ,
450
+ "[0] track 3 | hyphen-ok" ,
451
+ "[0] track 4" ,
452
+ "[0] track 5 | hyphen-ok, hyphen-ok-prefix" ,
453
+ ],
454
+ )
455
+
456
+ out = StringIO ()
457
+ call_command (* command , "--hyphen-ok-prefix" , "list" , stdout = out )
458
+ plan = self .lines (out .getvalue (), no_color = no_color )
459
+ self .assertEqual (
460
+ plan ,
461
+ [
462
+ "[0] track 1 | hyphen-ok, hyphen-ok-prefix" ,
463
+ "[0] track 2" ,
464
+ "[0] track 4" ,
465
+ "[0] track 5 | hyphen-ok, hyphen-ok-prefix" ,
466
+ ],
467
+ )
468
+
414
469
def test_list_color (self ):
415
470
self .test_list (no_color = False )
416
471
@@ -460,9 +515,10 @@ def test_subprocess(self):
460
515
│ --skip-checks Skip system checks. │
461
516
╰──────────────────────────────────────────────────────────────────────────────╯
462
517
╭─ Commands ───────────────────────────────────────────────────────────────────╮
463
- │ bad Bad command test routine │
464
- │ deploy Deploy the site application into production. │
465
- │ test Test Routine 1 │
518
+ │ bad Bad command test routine │
519
+ │ deploy Deploy the site application into production. │
520
+ │ test Test Routine 1 │
521
+ │ test-hyphen Test that hyphens dont mess everything up. │
466
522
╰──────────────────────────────────────────────────────────────────────────────╯
467
523
"""
468
524
@@ -547,9 +603,10 @@ def test_helps_rich(self):
547
603
--help Show this message and exit.
548
604
549
605
Commands:
550
- bad Bad command test routine
551
- deploy Deploy the site application into production.
552
- test Test Routine 1
606
+ bad Bad command test routine
607
+ deploy Deploy the site application into production.
608
+ test Test Routine 1
609
+ test-hyphen Test that hyphens dont mess everything up.
553
610
"""
554
611
555
612
routine_test_help_no_rich = """
@@ -608,7 +665,6 @@ def test_helps_no_rich(self):
608
665
609
666
def test_settings_format (self ):
610
667
routines = getattr (settings , ROUTINE_SETTING )
611
-
612
668
self .assertEqual (
613
669
routines ["bad" ],
614
670
{
@@ -650,7 +706,7 @@ def test_settings_format(self):
650
706
"kind" : "management" ,
651
707
"options" : {},
652
708
"priority" : 0 ,
653
- "switches" : [ "prepare" ] ,
709
+ "switches" : ( "prepare" ,) ,
654
710
},
655
711
{
656
712
"command" : ("migrate" ,),
@@ -762,6 +818,55 @@ def test_settings_format(self):
762
818
"subprocess" : False ,
763
819
},
764
820
)
821
+ self .assertEqual (
822
+ routines ["test_hyphen" ],
823
+ {
824
+ "commands" : [
825
+ {
826
+ "command" : ("track" , "1" ),
827
+ "kind" : "management" ,
828
+ "options" : {},
829
+ "priority" : 0 ,
830
+ "switches" : ("hyphen_ok" , "hyphen_ok_prefix" ),
831
+ },
832
+ {
833
+ "command" : ("track" , "2" ),
834
+ "kind" : "management" ,
835
+ "options" : {},
836
+ "priority" : 0 ,
837
+ "switches" : (),
838
+ },
839
+ {
840
+ "command" : ("track" , "3" ),
841
+ "kind" : "management" ,
842
+ "options" : {},
843
+ "priority" : 0 ,
844
+ "switches" : ("hyphen_ok" ,),
845
+ },
846
+ {
847
+ "command" : ("track" , "4" ),
848
+ "kind" : "management" ,
849
+ "options" : {},
850
+ "priority" : 0 ,
851
+ "switches" : (),
852
+ },
853
+ {
854
+ "command" : ("track" , "5" ),
855
+ "kind" : "management" ,
856
+ "options" : {},
857
+ "priority" : 0 ,
858
+ "switches" : ("hyphen_ok" , "hyphen_ok_prefix" ),
859
+ },
860
+ ],
861
+ "help_text" : "Test that hyphens dont mess everything up." ,
862
+ "name" : "test_hyphen" ,
863
+ "subprocess" : False ,
864
+ "switch_helps" : {
865
+ "hyphen_ok" : "Test hyphen." ,
866
+ "hyphen_ok_prefix" : "Test hyphen with -- prefix." ,
867
+ },
868
+ },
869
+ )
765
870
766
871
767
872
class Test (CoreTests , TestCase ):
0 commit comments