Skip to content

Commit 7b9ad4c

Browse files
committed
test: add classmethod flag tests
1 parent bcec700 commit 7b9ad4c

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

tests/test_class.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ def test_class_inheritance():
6565
cls = Class(ExampleClassC)
6666
inherited_methods = [method for method in cls.methods if method.is_inherited]
6767
assert any(method.name == "inherited_method" for method in inherited_methods)
68+
69+
70+
def test_class_includes_classmethods_when_enabled():
71+
cls = Class(ExampleClassC, classmethod=True)
72+
assert "class_method" in [method.name for method in cls.methods]

tests/test_inspect.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from examples import ExampleClassA, example_function
1+
from examples import ExampleClassA, ExampleClassC, example_function
22

33
from objinspect import Class, Function, Method, inspect
44

@@ -13,3 +13,11 @@ def test_correct_return_types():
1313
def test_method_of_instance():
1414
obj = inspect(ExampleClassA("a", 1).method_1)
1515
assert isinstance(obj, Method)
16+
17+
18+
def test_inspect_classmethod_flag():
19+
default_obj = inspect(ExampleClassC)
20+
assert "class_method" not in [method.name for method in default_obj.methods]
21+
22+
enabled_obj = inspect(ExampleClassC, classmethod=True)
23+
assert "class_method" in [method.name for method in enabled_obj.methods]

0 commit comments

Comments
 (0)