@@ -47,8 +47,13 @@ def test_code_directive(app: SphinxTestApp) -> None:
4747 )
4848
4949
50+ def _as_element (node : nodes .Node ) -> nodes .Element :
51+ assert isinstance (node , nodes .Element )
52+ return node
53+
54+
5055@pytest .mark .sphinx ('html' , testroot = 'directive-csv-table' )
51- def test_csv_table_directive (app ) :
56+ def test_csv_table_directive (app : SphinxTestApp ) -> None :
5257 # relative path from current document
5358 text = '.. csv-table::\n :file: example.csv\n '
5459 doctree = restructuredtext .parse (app , text , docname = 'subdir/index' )
@@ -62,8 +67,12 @@ def test_csv_table_directive(app):
6267 ],
6368 ),
6469 )
70+ table = _as_element (doctree [0 ])
71+ tgroup = _as_element (table [0 ])
72+ tbody = _as_element (tgroup [3 ])
73+ first_row = _as_element (tbody [0 ])
6574 assert_node (
66- doctree [ 0 ][ 0 ][ 3 ][ 0 ] ,
75+ first_row ,
6776 (
6877 [nodes .entry , nodes .paragraph , 'FOO' ],
6978 [nodes .entry , nodes .paragraph , 'BAR' ],
@@ -84,8 +93,12 @@ def test_csv_table_directive(app):
8493 ],
8594 ),
8695 )
96+ table = _as_element (doctree [0 ])
97+ tgroup = _as_element (table [0 ])
98+ tbody = _as_element (tgroup [3 ])
99+ first_row = _as_element (tbody [0 ])
87100 assert_node (
88- doctree [ 0 ][ 0 ][ 3 ][ 0 ] ,
101+ first_row ,
89102 (
90103 [nodes .entry , nodes .paragraph , 'foo' ],
91104 [nodes .entry , nodes .paragraph , 'bar' ],
0 commit comments