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

Download this file

45 lines (30 with data), 922 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
38
39
40
41
42
43
44
import pytest
from ehrql.docs.schemas import get_table_docstring
from ehrql.tables import EventFrame, Series, table
def test_get_table_docstring():
@table
class parent_table(EventFrame):
"I have a docstring"
col_a = Series(str)
@table
class child_table(parent_table.__class__):
"""
I have a docstring
With some extra stuff
"""
col_b = Series(str)
assert (
get_table_docstring(child_table.__class__)
== "I have a docstring\n\nWith some extra stuff"
)
def test_get_table_docstring_with_mismatch():
@table
class parent_table(EventFrame):
"I have a docstring"
col_a = Series(str)
@table
class child_table(parent_table.__class__):
"I have a different docstring"
col_b = Series(str)
with pytest.raises(ValueError):
get_table_docstring(child_table.__class__)