@@ -1365,6 +1365,9 @@ def test_columnize(capsys: pytest.CaptureFixture[str]) -> None:
13651365class HelpCategoriesApp (cmd2 .Cmd ):
13661366 """Class for testing custom help_* methods which override docstring help."""
13671367
1368+ SOME_CATEGORY = "Some Category"
1369+ CUSTOM_CATEGORY = "Custom Category"
1370+
13681371 def __init__ (self , * args , ** kwargs ) -> None :
13691372 super ().__init__ (* args , ** kwargs )
13701373
@@ -1373,10 +1376,11 @@ def do_diddly(self, arg) -> None:
13731376 """This command does diddly"""
13741377
13751378 # This command will be in the "Some Category" section of the help menu even though it has no docstring
1376- @cmd2 .with_category ("Some Category" )
1379+ @cmd2 .with_category (SOME_CATEGORY )
13771380 def do_cat_nodoc (self , arg ) -> None :
13781381 pass
13791382
1383+ # This command will show in the category labeled with self.default_category
13801384 def do_squat (self , arg ) -> None :
13811385 """This docstring help will never be shown because the help_squat method overrides it."""
13821386
@@ -1386,7 +1390,7 @@ def help_squat(self) -> None:
13861390 def do_edit (self , arg ) -> None :
13871391 """This overrides the edit command and does nothing."""
13881392
1389- cmd2 .categorize ((do_squat , do_edit ), 'Custom Category' )
1393+ cmd2 .categorize ((do_squat , do_edit ), CUSTOM_CATEGORY )
13901394
13911395 # This command will be in the "undocumented" section of the help menu
13921396 def do_undoc (self , arg ) -> None :
@@ -1403,12 +1407,22 @@ def test_help_cat_base(helpcat_app) -> None:
14031407 assert helpcat_app .last_result is True
14041408 verify_help_text (helpcat_app , out )
14051409
1410+ help_text = '' .join (out )
1411+ assert helpcat_app .CUSTOM_CATEGORY in help_text
1412+ assert helpcat_app .SOME_CATEGORY in help_text
1413+ assert helpcat_app .default_category in help_text
1414+
14061415
14071416def test_help_cat_verbose (helpcat_app ) -> None :
14081417 out , err = run_cmd (helpcat_app , 'help --verbose' )
14091418 assert helpcat_app .last_result is True
14101419 verify_help_text (helpcat_app , out )
14111420
1421+ help_text = '' .join (out )
1422+ assert helpcat_app .CUSTOM_CATEGORY in help_text
1423+ assert helpcat_app .SOME_CATEGORY in help_text
1424+ assert helpcat_app .default_category in help_text
1425+
14121426
14131427class SelectApp (cmd2 .Cmd ):
14141428 def do_eat (self , arg ) -> None :
0 commit comments