Skip to content

Commit 1dda279

Browse files
committed
Added missing test coverage.
1 parent b5c9618 commit 1dda279

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/test_utils.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,37 @@ def bar(self, x: bool) -> None:
396396
param_name, param_value = next(iter(param_ann.items()))
397397
assert param_name == "x"
398398
assert param_value is bool
399+
400+
401+
def test_categorize() -> None:
402+
from cmd2 import constants
403+
404+
category = "Test Category"
405+
attr_name = constants.COMMAND_ATTR_HELP_CATEGORY
406+
407+
# Test single function
408+
def func1() -> None:
409+
pass
410+
411+
cu.categorize(func1, category)
412+
assert getattr(func1, attr_name) == category
413+
414+
# Test iterable of functions
415+
def func2() -> None:
416+
pass
417+
418+
def func3() -> None:
419+
pass
420+
421+
cu.categorize([func2, func3], category)
422+
assert getattr(func2, attr_name) == category
423+
assert getattr(func3, attr_name) == category
424+
425+
# Test bound method
426+
class Foo:
427+
def bar(self) -> None:
428+
pass
429+
430+
f = Foo()
431+
cu.categorize(f.bar, category)
432+
assert getattr(Foo.bar, attr_name) == category

0 commit comments

Comments
 (0)