5
5
from sphinx .testing .util import assert_node
6
6
7
7
from sphinxcontrib .autodoc_pydantic import PydanticModelDocumenter
8
- from .compatibility import desc_annotation_directive_prefix , package_is_missing
8
+ from .compatibility import desc_annotation_directive_prefix
9
9
10
10
KWARGS = dict (documenter = PydanticModelDocumenter .objtype , deactivate_all = True )
11
11
@@ -97,8 +97,9 @@ def test_autodoc_pydantic_model_show_json_false(autodocument):
97
97
assert actual == result
98
98
99
99
100
- @pytest .mark .skipif (package_is_missing ('erdantic' ), reason = 'erdantic missing' )
101
100
def test_autodoc_pydantic_model_erdantic_figure_true (autodocument ):
101
+ pytest .importorskip ('erdantic' , minversion = '1.0' , reason = 'erdantic missing' )
102
+
102
103
kwargs = dict (object_path = 'target.configuration.ModelErdanticFigure' , ** KWARGS )
103
104
104
105
result = [
@@ -116,24 +117,27 @@ def test_autodoc_pydantic_model_erdantic_figure_true(autodocument):
116
117
'' ,
117
118
' .. graphviz::' ,
118
119
'' ,
119
- ' digraph "Entity Relationship Diagram" {' ,
120
+ ' digraph "Entity Relationship Diagram created by erdantic " {' ,
120
121
' graph [fontcolor=gray66,' ,
122
+ ' fontname="Times New Roman,Times,Liberation Serif,serif",' ,
121
123
' fontsize=9,' ,
122
- ' label="Created by erdantic v0.5.0 <https://github.com/drivendataorg/erdantic>",' ,
123
124
' nodesep=0.5,' ,
124
125
' rankdir=LR,' ,
125
126
' ranksep=1.5' ,
126
127
' ];' ,
127
- ' node [fontsize=14,' ,
128
+ ' node [fontname="Times New Roman,Times,Liberation Serif,serif",' ,
129
+ ' fontsize=14,' ,
128
130
' label="\\ N",' ,
129
131
' shape=plain' ,
130
132
' ];' ,
133
+ ' edge [dir=both];' ,
131
134
' "target.configuration.ModelErdanticFigure" [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ModelErdanticFigure</b></td></tr><tr><td>field1</td><td port="field1">int</td></tr><tr><td>field2</td><td port="field2">str</td></tr><tr><td>related</td><td port="related">ModelErdanticFigureRelated</td></tr></table>>,' ,
132
135
' tooltip="target.configuration.ModelErdanticFigure

ModelErdanticFigure.
"];' ,
133
136
' "target.configuration.ModelErdanticFigureRelated" [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ModelErdanticFigureRelated</b></td></tr><tr><td>field1</td><td port="field1">int</td></tr><tr><td>field2</td><td port="field2">str</td></tr></table>>,' ,
134
137
' tooltip="target.configuration.ModelErdanticFigureRelated

ModelErdanticFigureRelated.
"];' ,
135
- ' "target.configuration.ModelErdanticFigure":related:e -> "target.configuration.ModelErdanticFigureRelated":_root:w [arrowhead=noneteetee];' ,
136
- ' }' '' ,
138
+ ' "target.configuration.ModelErdanticFigure":related:e -> "target.configuration.ModelErdanticFigureRelated":_root:w [arrowhead=noneteetee,' ,
139
+ ' arrowtail=nonenone];' ,
140
+ ' }' ,
137
141
'' ,
138
142
'' ,
139
143
'' ,
@@ -143,31 +147,28 @@ def test_autodoc_pydantic_model_erdantic_figure_true(autodocument):
143
147
'' ,
144
148
'' ,
145
149
]
146
-
147
150
# explicit global
148
151
actual = autodocument (
149
152
options_app = {'autodoc_pydantic_model_erdantic_figure' : True }, ** kwargs
150
153
)
151
- assert actual [:17 ] == result [:17 ]
152
- assert actual [18 :] == result [18 :]
154
+ assert actual == result
153
155
154
156
# explicit local
155
157
actual = autodocument (options_doc = {'model-erdantic-figure' : True }, ** kwargs )
156
- assert actual [:17 ] == result [:17 ]
157
- assert actual [18 :] == result [18 :]
158
+ assert actual == result
158
159
159
160
# explicit local overwrite global
160
161
actual = autodocument (
161
162
options_app = {'autodoc_pydantic_model_erdantic_figure' : False },
162
163
options_doc = {'model-erdantic-figure' : True },
163
164
** kwargs ,
164
165
)
165
- assert actual [:17 ] == result [:17 ]
166
- assert actual [18 :] == result [18 :]
166
+ assert actual == result
167
167
168
168
169
- @pytest .mark .skipif (package_is_missing ('erdantic' ), reason = 'erdantic missing' )
170
169
def test_autodoc_pydantic_model_erdantic_figure_collapsed_false (autodocument ):
170
+ pytest .importorskip ('erdantic' , minversion = '1.0' , reason = 'erdantic missing' )
171
+
171
172
kwargs = dict (object_path = 'target.configuration.ModelErdanticFigure' , ** KWARGS )
172
173
173
174
result = [
@@ -179,23 +180,26 @@ def test_autodoc_pydantic_model_erdantic_figure_collapsed_false(autodocument):
179
180
'' ,
180
181
' .. graphviz::' ,
181
182
'' ,
182
- ' digraph "Entity Relationship Diagram" {' ,
183
+ ' digraph "Entity Relationship Diagram created by erdantic " {' ,
183
184
' graph [fontcolor=gray66,' ,
185
+ ' fontname="Times New Roman,Times,Liberation Serif,serif",' ,
184
186
' fontsize=9,' ,
185
- ' label="Created by erdantic v0.5.0 <https://github.com/drivendataorg/erdantic>",' ,
186
187
' nodesep=0.5,' ,
187
188
' rankdir=LR,' ,
188
189
' ranksep=1.5' ,
189
190
' ];' ,
190
- ' node [fontsize=14,' ,
191
+ ' node [fontname="Times New Roman,Times,Liberation Serif,serif",' ,
192
+ ' fontsize=14,' ,
191
193
' label="\\ N",' ,
192
194
' shape=plain' ,
193
195
' ];' ,
196
+ ' edge [dir=both];' ,
194
197
' "target.configuration.ModelErdanticFigure" [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ModelErdanticFigure</b></td></tr><tr><td>field1</td><td port="field1">int</td></tr><tr><td>field2</td><td port="field2">str</td></tr><tr><td>related</td><td port="related">ModelErdanticFigureRelated</td></tr></table>>,' ,
195
198
' tooltip="target.configuration.ModelErdanticFigure

ModelErdanticFigure.
"];' ,
196
199
' "target.configuration.ModelErdanticFigureRelated" [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>ModelErdanticFigureRelated</b></td></tr><tr><td>field1</td><td port="field1">int</td></tr><tr><td>field2</td><td port="field2">str</td></tr></table>>,' ,
197
200
' tooltip="target.configuration.ModelErdanticFigureRelated

ModelErdanticFigureRelated.
"];' ,
198
- ' "target.configuration.ModelErdanticFigure":related:e -> "target.configuration.ModelErdanticFigureRelated":_root:w [arrowhead=noneteetee];' ,
201
+ ' "target.configuration.ModelErdanticFigure":related:e -> "target.configuration.ModelErdanticFigureRelated":_root:w [arrowhead=noneteetee,' ,
202
+ ' arrowtail=nonenone];' ,
199
203
' }' ,
200
204
'' ,
201
205
'' ,
@@ -209,8 +213,7 @@ def test_autodoc_pydantic_model_erdantic_figure_collapsed_false(autodocument):
209
213
},
210
214
** kwargs ,
211
215
)
212
- assert actual [:11 ] == result [:11 ]
213
- assert actual [12 :] == result [12 :]
216
+ assert actual == result
214
217
215
218
# explicit local
216
219
actual = autodocument (
@@ -220,8 +223,7 @@ def test_autodoc_pydantic_model_erdantic_figure_collapsed_false(autodocument):
220
223
},
221
224
** kwargs ,
222
225
)
223
- assert actual [:11 ] == result [:11 ]
224
- assert actual [12 :] == result [12 :]
226
+ assert actual == result
225
227
226
228
# explicit local overwrite global
227
229
actual = autodocument (
@@ -232,12 +234,12 @@ def test_autodoc_pydantic_model_erdantic_figure_collapsed_false(autodocument):
232
234
},
233
235
** kwargs ,
234
236
)
235
- assert actual [:11 ] == result [:11 ]
236
- assert actual [12 :] == result [12 :]
237
+ assert actual == result
237
238
238
239
239
- @pytest .mark .skipif (package_is_missing ('erdantic' ), reason = 'erdantic missing' )
240
240
def test_autodoc_pydantic_model_erdantic_figure_false (autodocument ):
241
+ pytest .importorskip ('erdantic' , minversion = '1.0' , reason = 'erdantic missing' )
242
+
241
243
kwargs = dict (object_path = 'target.configuration.ModelErdanticFigure' , ** KWARGS )
242
244
243
245
result = [
0 commit comments