@@ -895,8 +895,8 @@ def test_base_debug(base_app) -> None:
895
895
896
896
# Make sure we get an exception, but cmd2 handles it
897
897
out , err = run_cmd (base_app , 'edit' )
898
- assert "EXCEPTION of type " in err [0 ]
899
- assert "Please use 'set editor' " in err [0 ]
898
+ assert "ValueError: Please use 'set editor' " in err [0 ]
899
+ assert "To enable full traceback " in err [3 ]
900
900
901
901
# Set debug true
902
902
out , err = run_cmd (base_app , 'set debug True' )
@@ -918,11 +918,20 @@ def test_debug_not_settable(base_app) -> None:
918
918
base_app .debug = False
919
919
base_app .remove_settable ('debug' )
920
920
921
- # Cause an exception
922
- out , err = run_cmd (base_app , 'bad "quote' )
921
+ # Cause an exception by setting editor to None and running edit
922
+ base_app .editor = None
923
+ out , err = run_cmd (base_app , 'edit' )
923
924
924
925
# Since debug is unsettable, the user will not be given the option to enable a full traceback
925
- assert err == ['Invalid syntax: No closing quotation' ]
926
+ assert err == ["ValueError: Please use 'set editor' to specify your text editing program of" , 'choice.' ]
927
+
928
+
929
+ def test_blank_exception (mocker , base_app ):
930
+ mocker .patch ("cmd2.Cmd.do_help" , side_effect = Exception )
931
+ out , err = run_cmd (base_app , 'help' )
932
+
933
+ # When an exception has no message, the first error line is just its type.
934
+ assert err [0 ] == "Exception"
926
935
927
936
928
937
def test_remove_settable_keyerror (base_app ) -> None :
@@ -2668,8 +2677,7 @@ def test_pexcept_style(base_app, capsys) -> None:
2668
2677
2669
2678
base_app .pexcept (msg )
2670
2679
out , err = capsys .readouterr ()
2671
- expected = su .stylize ("EXCEPTION of type " , style = Cmd2Style .ERROR )
2672
- expected += su .stylize ("Exception" , style = Cmd2Style .EXCEPTION_TYPE )
2680
+ expected = su .stylize ("Exception: " , style = "traceback.exc_type" )
2673
2681
assert err .startswith (expected )
2674
2682
2675
2683
@@ -2679,17 +2687,7 @@ def test_pexcept_no_style(base_app, capsys) -> None:
2679
2687
2680
2688
base_app .pexcept (msg )
2681
2689
out , err = capsys .readouterr ()
2682
- assert err .startswith ("EXCEPTION of type Exception occurred with message: testing..." )
2683
-
2684
-
2685
- @with_ansi_style (ru .AllowStyle .NEVER )
2686
- def test_pexcept_not_exception (base_app , capsys ) -> None :
2687
- # Pass in a msg that is not an Exception object
2688
- msg = False
2689
-
2690
- base_app .pexcept (msg )
2691
- out , err = capsys .readouterr ()
2692
- assert err .startswith ("EXCEPTION of type bool occurred with message: False" )
2690
+ assert err .startswith ("Exception: testing..." )
2693
2691
2694
2692
2695
2693
@pytest .mark .parametrize ('chop' , [True , False ])
0 commit comments