Skip to content

Commit 671e93e

Browse files
committed
Test for Subgroup
1 parent 32e2c48 commit 671e93e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,20 @@ def test_annotation_template(annotation_template: AnnotationTemplate, input_reso
9090
[(int, Any), ((tuple | list, Iterable), Iterable), ((str, Sized), Sized)]
9191
)
9292
def test_special(input_resource: Any, result: Any):
93-
assert Special[input_resource] == result
93+
assert Special[input_resource] == result
94+
95+
96+
@mark.parametrize(
97+
"subgroup, instance, result_of_checking",
98+
[
99+
(Subgroup(object, lambda _: True), 1, True),
100+
(Subgroup(object, lambda _: True), None, True),
101+
(Subgroup(object, lambda _: False), 256, False),
102+
(Subgroup(int, lambda number: number > 0), 5, True),
103+
(Subgroup(int, lambda number: number > 0), -42, False),
104+
(Subgroup(int, lambda number: number > 0), 6.4, False),
105+
(Subgroup(int | float, lambda number: number > 0), 6.4, True),
106+
]
107+
)
108+
def test_subgroup(subgroup: Subgroup, instance: Any, result_of_checking: bool):
109+
assert isinstance(instance, subgroup) is (instance in subgroup) is result_of_checking

0 commit comments

Comments
 (0)