|
11 | 11 | from docutils.utils import new_document |
12 | 12 |
|
13 | 13 | from sphinx.transforms import ApplySourceWorkaround |
14 | | -from sphinx.util.nodes import (NodeMatcher, clean_astext, extract_messages, make_id, |
15 | | - split_explicit_title) |
| 14 | +from sphinx.util.nodes import (NodeMatcher, apply_source_workaround, clean_astext, |
| 15 | + extract_messages, make_id, split_explicit_title) |
16 | 16 |
|
17 | 17 |
|
18 | 18 | def _transform(doctree): |
@@ -226,3 +226,23 @@ def test_make_id_sequential(app): |
226 | 226 | ) |
227 | 227 | def test_split_explicit_target(title, expected): |
228 | 228 | assert expected == split_explicit_title(title) |
| 229 | + |
| 230 | + |
| 231 | +def test_apply_source_workaround_literal_block_no_source(): |
| 232 | + """Regression test for #11091. |
| 233 | +
|
| 234 | + Test that apply_source_workaround doesn't raise. |
| 235 | + """ |
| 236 | + literal_block = nodes.literal_block('', '') |
| 237 | + list_item = nodes.list_item('', literal_block) |
| 238 | + bullet_list = nodes.bullet_list('', list_item) |
| 239 | + |
| 240 | + assert literal_block.source is None |
| 241 | + assert list_item.source is None |
| 242 | + assert bullet_list.source is None |
| 243 | + |
| 244 | + apply_source_workaround(literal_block) |
| 245 | + |
| 246 | + assert literal_block.source is None |
| 247 | + assert list_item.source is None |
| 248 | + assert bullet_list.source is None |
0 commit comments