[e988c2]: / tests / unit / docs / test_language.py

Download this file

38 lines (28 with data), 849 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pytest
from ehrql.docs.language import is_included_attr
from ehrql.utils.docs_utils import exclude_from_docs
class Example:
some_attr = "some_value"
def some_method(self):
raise NotImplementedError()
@property
def some_property(self):
raise NotImplementedError()
def _some_internal_method(self):
raise NotImplementedError()
@exclude_from_docs
def some_excluded_method(self):
raise NotImplementedError()
@pytest.mark.parametrize(
"name,expected",
[
("some_attr", False),
("some_method", True),
("some_property", True),
("_some_internal_method", False),
("some_excluded_method", False),
],
)
def test_is_included_attr(name, expected):
value = getattr(Example, name)
assert is_included_attr(name, value) == expected