@@ -1252,7 +1252,7 @@ def test_command_line(self, settings=None):
1252
1252
1253
1253
self .assertEqual (get_command ("groups" ).echo (message = "hey!" ).strip (), "hey!" )
1254
1254
1255
- result = run_command ("groups" , * settings , "echo" , "hey!" , "5" )
1255
+ result = run_command ("groups" , "--no-color" , * settings , "echo" , "hey!" , "5" )
1256
1256
if override :
1257
1257
self .assertEqual (result [0 ].strip (), ("hey! " * 5 ).strip ())
1258
1258
self .assertEqual (
@@ -1413,7 +1413,15 @@ def test_command_line(self, settings=None):
1413
1413
self .assertEqual (grp_cmd .lower (4 , 9 ), "ANNAmonteS" )
1414
1414
1415
1415
result = run_command (
1416
- "groups" , * settings , "string" , "annamontes" , "case" , "upper" , "4" , "9"
1416
+ "groups" ,
1417
+ "--no-color" ,
1418
+ * settings ,
1419
+ "string" ,
1420
+ "annamontes" ,
1421
+ "case" ,
1422
+ "upper" ,
1423
+ "4" ,
1424
+ "9" ,
1417
1425
)
1418
1426
if override :
1419
1427
self .assertIn (
@@ -2634,12 +2642,12 @@ class TracebackTests(TestCase):
2634
2642
"""
2635
2643
2636
2644
def test_usage_error_no_tb (self ):
2637
- stdout , stderr , retcode = run_command ("tb" , "wrong" )
2645
+ stdout , stderr , retcode = run_command ("tb" , "--no-color" , " wrong" )
2638
2646
self .assertTrue ("Usage: ./manage.py tb [OPTIONS] COMMAND [ARGS]" in stdout )
2639
2647
self .assertTrue ("No such command" in stderr )
2640
2648
self .assertTrue (retcode > 0 )
2641
2649
2642
- stdout , stderr , retcode = run_command ("tb" , "error" , "wrong" )
2650
+ stdout , stderr , retcode = run_command ("tb" , "--no-color" , " error" , "wrong" )
2643
2651
self .assertTrue ("Usage: ./manage.py tb error [OPTIONS]" in stdout )
2644
2652
self .assertTrue ("Got unexpected extra argument" in stderr )
2645
2653
self .assertTrue (retcode > 0 )
@@ -2652,7 +2660,9 @@ def test_usage_error_no_tb(self):
2652
2660
2653
2661
def test_usage_error_with_tb_if_requested (self ):
2654
2662
2655
- stdout , stderr , retcode = run_command ("tb" , "--traceback" , "wrong" )
2663
+ stdout , stderr , retcode = run_command (
2664
+ "tb" , "--no-color" , "--traceback" , "wrong"
2665
+ )
2656
2666
self .assertFalse (stdout .strip ())
2657
2667
self .assertTrue ("Traceback" in stderr )
2658
2668
if rich_installed :
@@ -2662,7 +2672,9 @@ def test_usage_error_with_tb_if_requested(self):
2662
2672
self .assertTrue ("No such command 'wrong'" in stderr )
2663
2673
self .assertTrue (retcode > 0 )
2664
2674
2665
- stdout , stderr , retcode = run_command ("tb" , "--traceback" , "error" , "wrong" )
2675
+ stdout , stderr , retcode = run_command (
2676
+ "tb" , "--no-color" , "--traceback" , "error" , "wrong"
2677
+ )
2666
2678
self .assertFalse (stdout .strip ())
2667
2679
self .assertTrue ("Traceback" in stderr )
2668
2680
if rich_installed :
@@ -2705,3 +2717,31 @@ def test_exit_on_call(self):
2705
2717
2706
2718
with self .assertRaises (SystemExit ):
2707
2719
call_command ("tb" , "exit" , "--code=1" )
2720
+
2721
+
2722
+ class TestHandleAsInit (TestCase ):
2723
+
2724
+ def test_handle_as_init_run (self ):
2725
+
2726
+ stdout , stderr , retcode = run_command ("handle_as_init" )
2727
+ self .assertTrue ("handle" in stdout )
2728
+ self .assertFalse (stderr .strip ())
2729
+ self .assertEqual (retcode , 0 )
2730
+
2731
+ stdout , stderr , retcode = run_command ("handle_as_init" , "subcommand" )
2732
+ self .assertTrue ("subcommand" in stdout )
2733
+ self .assertFalse (stderr .strip ())
2734
+ self .assertEqual (retcode , 0 )
2735
+
2736
+ def test_handle_as_init_call (self ):
2737
+
2738
+ self .assertEqual (call_command ("handle_as_init" ).strip (), "handle" )
2739
+ self .assertEqual (
2740
+ call_command ("handle_as_init" , "subcommand" ).strip (), "subcommand"
2741
+ )
2742
+
2743
+ def test_handle_as_init_direct (self ):
2744
+
2745
+ self .assertEqual (get_command ("handle_as_init" )(), "handle" )
2746
+ self .assertEqual (get_command ("handle_as_init" , "subcommand" )(), "subcommand" )
2747
+ self .assertEqual (get_command ("handle_as_init" ).subcommand (), "subcommand" )
0 commit comments