@@ -1365,6 +1365,9 @@ def test_columnize(capsys: pytest.CaptureFixture[str]) -> None:
1365
1365
class HelpCategoriesApp (cmd2 .Cmd ):
1366
1366
"""Class for testing custom help_* methods which override docstring help."""
1367
1367
1368
+ SOME_CATEGORY = "Some Category"
1369
+ CUSTOM_CATEGORY = "Custom Category"
1370
+
1368
1371
def __init__ (self , * args , ** kwargs ) -> None :
1369
1372
super ().__init__ (* args , ** kwargs )
1370
1373
@@ -1373,10 +1376,11 @@ def do_diddly(self, arg) -> None:
1373
1376
"""This command does diddly"""
1374
1377
1375
1378
# 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 )
1377
1380
def do_cat_nodoc (self , arg ) -> None :
1378
1381
pass
1379
1382
1383
+ # This command will show in the category labeled with self.default_category
1380
1384
def do_squat (self , arg ) -> None :
1381
1385
"""This docstring help will never be shown because the help_squat method overrides it."""
1382
1386
@@ -1386,7 +1390,7 @@ def help_squat(self) -> None:
1386
1390
def do_edit (self , arg ) -> None :
1387
1391
"""This overrides the edit command and does nothing."""
1388
1392
1389
- cmd2 .categorize ((do_squat , do_edit ), 'Custom Category' )
1393
+ cmd2 .categorize ((do_squat , do_edit ), CUSTOM_CATEGORY )
1390
1394
1391
1395
# This command will be in the "undocumented" section of the help menu
1392
1396
def do_undoc (self , arg ) -> None :
@@ -1403,12 +1407,23 @@ def test_help_cat_base(helpcat_app) -> None:
1403
1407
assert helpcat_app .last_result is True
1404
1408
verify_help_text (helpcat_app , out )
1405
1409
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
+
1415
+
1406
1416
1407
1417
def test_help_cat_verbose (helpcat_app ) -> None :
1408
1418
out , err = run_cmd (helpcat_app , 'help --verbose' )
1409
1419
assert helpcat_app .last_result is True
1410
1420
verify_help_text (helpcat_app , out )
1411
1421
1422
+ help_text = '' .join (out )
1423
+ assert helpcat_app .CUSTOM_CATEGORY in help_text
1424
+ assert helpcat_app .SOME_CATEGORY in help_text
1425
+ assert helpcat_app .default_category in help_text
1426
+
1412
1427
1413
1428
class SelectApp (cmd2 .Cmd ):
1414
1429
def do_eat (self , arg ) -> None :
0 commit comments