| 1 |
"""Test the HTML builder and check output against XPath.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
import re |
| 6 |
from typing import TYPE_CHECKING |
| 7 |
|
| 8 |
import pytest |
| 9 |
|
| 10 |
from tests.test_builders.xpath_data import FIGURE_CAPTION |
| 11 |
from tests.test_builders.xpath_util import check_xpath |
| 12 |
|
| 13 |
if TYPE_CHECKING: |
| 14 |
from collections.abc import Callable |
| 15 |
from pathlib import Path |
| 16 |
from xml.etree.ElementTree import ElementTree |
| 17 |
|
| 18 |
from sphinx.testing.util import SphinxTestApp |
| 19 |
|
| 20 |
|
| 21 |
@pytest.mark.sphinx('html', testroot='numfig') |
| 22 |
@pytest.mark.test_params(shared_result='test_build_html_numfig') |
| 23 |
def test_numfig_disabled_warn(app: SphinxTestApp) -> None: |
| 24 |
app.build() |
| 25 |
warnings = app.warning.getvalue() |
| 26 |
assert 'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' in warnings |
| 27 |
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' not in warnings |
| 28 |
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' not in warnings |
| 29 |
|
| 30 |
|
| 31 |
@pytest.mark.parametrize( |
| 32 |
('fname', 'path', 'check', 'be_found'), |
| 33 |
[ |
| 34 |
('index.html', FIGURE_CAPTION + "/span[@class='caption-number']", None, True), |
| 35 |
('index.html', ".//table/caption/span[@class='caption-number']", None, True), |
| 36 |
( |
| 37 |
'index.html', |
| 38 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 39 |
None, |
| 40 |
True, |
| 41 |
), |
| 42 |
('index.html', './/li/p/code/span', '^fig1$', True), |
| 43 |
('index.html', './/li/p/code/span', '^Figure%s$', True), |
| 44 |
('index.html', './/li/p/code/span', '^table-1$', True), |
| 45 |
('index.html', './/li/p/code/span', '^Table:%s$', True), |
| 46 |
('index.html', './/li/p/code/span', '^CODE_1$', True), |
| 47 |
('index.html', './/li/p/code/span', '^Code-%s$', True), |
| 48 |
('index.html', './/li/p/a/span', '^Section 1$', True), |
| 49 |
('index.html', './/li/p/a/span', '^Section 2.1$', True), |
| 50 |
('index.html', './/li/p/code/span', '^Fig.{number}$', True), |
| 51 |
('index.html', './/li/p/a/span', '^Sect.1 Foo$', True), |
| 52 |
('foo.html', FIGURE_CAPTION + "/span[@class='caption-number']", None, True), |
| 53 |
('foo.html', ".//table/caption/span[@class='caption-number']", None, True), |
| 54 |
( |
| 55 |
'foo.html', |
| 56 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 57 |
None, |
| 58 |
True, |
| 59 |
), |
| 60 |
('bar.html', FIGURE_CAPTION + "/span[@class='caption-number']", None, True), |
| 61 |
('bar.html', ".//table/caption/span[@class='caption-number']", None, True), |
| 62 |
( |
| 63 |
'bar.html', |
| 64 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 65 |
None, |
| 66 |
True, |
| 67 |
), |
| 68 |
('baz.html', FIGURE_CAPTION + "/span[@class='caption-number']", None, True), |
| 69 |
('baz.html', ".//table/caption/span[@class='caption-number']", None, True), |
| 70 |
( |
| 71 |
'baz.html', |
| 72 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 73 |
None, |
| 74 |
True, |
| 75 |
), |
| 76 |
], |
| 77 |
) |
| 78 |
@pytest.mark.sphinx('html', testroot='numfig') |
| 79 |
@pytest.mark.test_params(shared_result='test_build_html_numfig') |
| 80 |
def test_numfig_disabled( |
| 81 |
app: SphinxTestApp, |
| 82 |
cached_etree_parse: Callable[[Path], ElementTree], |
| 83 |
fname: str, |
| 84 |
path: str, |
| 85 |
check: str | None, |
| 86 |
be_found: bool, |
| 87 |
) -> None: |
| 88 |
app.build() |
| 89 |
check_xpath(cached_etree_parse(app.outdir / fname), fname, path, check, be_found) |
| 90 |
|
| 91 |
|
| 92 |
@pytest.mark.sphinx( |
| 93 |
'html', |
| 94 |
testroot='numfig', |
| 95 |
srcdir='test_numfig_without_numbered_toctree_warn', |
| 96 |
confoverrides={'numfig': True}, |
| 97 |
) |
| 98 |
def test_numfig_without_numbered_toctree_warn(app: SphinxTestApp) -> None: |
| 99 |
app.build() |
| 100 |
# remove :numbered: option |
| 101 |
index = (app.srcdir / 'index.rst').read_text(encoding='utf8') |
| 102 |
index = re.sub(':numbered:.*', '', index) |
| 103 |
(app.srcdir / 'index.rst').write_text(index, encoding='utf8') |
| 104 |
app.build() |
| 105 |
|
| 106 |
warnings = app.warning.getvalue() |
| 107 |
assert ( |
| 108 |
'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' |
| 109 |
) not in warnings |
| 110 |
assert ( |
| 111 |
'index.rst:55: WARNING: Failed to create a cross reference. Any number is not assigned: index' |
| 112 |
) in warnings |
| 113 |
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' in warnings |
| 114 |
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings |
| 115 |
|
| 116 |
|
| 117 |
@pytest.mark.parametrize( |
| 118 |
('fname', 'path', 'check', 'be_found'), |
| 119 |
[ |
| 120 |
( |
| 121 |
'index.html', |
| 122 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 123 |
'^Fig. 9 $', |
| 124 |
True, |
| 125 |
), |
| 126 |
( |
| 127 |
'index.html', |
| 128 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 129 |
'^Fig. 10 $', |
| 130 |
True, |
| 131 |
), |
| 132 |
( |
| 133 |
'index.html', |
| 134 |
".//table/caption/span[@class='caption-number']", |
| 135 |
'^Table 9 $', |
| 136 |
True, |
| 137 |
), |
| 138 |
( |
| 139 |
'index.html', |
| 140 |
".//table/caption/span[@class='caption-number']", |
| 141 |
'^Table 10 $', |
| 142 |
True, |
| 143 |
), |
| 144 |
( |
| 145 |
'index.html', |
| 146 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 147 |
'^Listing 9 $', |
| 148 |
True, |
| 149 |
), |
| 150 |
( |
| 151 |
'index.html', |
| 152 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 153 |
'^Listing 10 $', |
| 154 |
True, |
| 155 |
), |
| 156 |
('index.html', './/li/p/a/span', '^Fig. 9$', True), |
| 157 |
('index.html', './/li/p/a/span', '^Figure6$', True), |
| 158 |
('index.html', './/li/p/a/span', '^Table 9$', True), |
| 159 |
('index.html', './/li/p/a/span', '^Table:6$', True), |
| 160 |
('index.html', './/li/p/a/span', '^Listing 9$', True), |
| 161 |
('index.html', './/li/p/a/span', '^Code-6$', True), |
| 162 |
('index.html', './/li/p/code/span', '^foo$', True), |
| 163 |
('index.html', './/li/p/code/span', '^bar_a$', True), |
| 164 |
('index.html', './/li/p/a/span', '^Fig.9 should be Fig.1$', True), |
| 165 |
('index.html', './/li/p/code/span', '^Sect.{number}$', True), |
| 166 |
( |
| 167 |
'foo.html', |
| 168 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 169 |
'^Fig. 1 $', |
| 170 |
True, |
| 171 |
), |
| 172 |
( |
| 173 |
'foo.html', |
| 174 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 175 |
'^Fig. 2 $', |
| 176 |
True, |
| 177 |
), |
| 178 |
( |
| 179 |
'foo.html', |
| 180 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 181 |
'^Fig. 3 $', |
| 182 |
True, |
| 183 |
), |
| 184 |
( |
| 185 |
'foo.html', |
| 186 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 187 |
'^Fig. 4 $', |
| 188 |
True, |
| 189 |
), |
| 190 |
( |
| 191 |
'foo.html', |
| 192 |
".//table/caption/span[@class='caption-number']", |
| 193 |
'^Table 1 $', |
| 194 |
True, |
| 195 |
), |
| 196 |
( |
| 197 |
'foo.html', |
| 198 |
".//table/caption/span[@class='caption-number']", |
| 199 |
'^Table 2 $', |
| 200 |
True, |
| 201 |
), |
| 202 |
( |
| 203 |
'foo.html', |
| 204 |
".//table/caption/span[@class='caption-number']", |
| 205 |
'^Table 3 $', |
| 206 |
True, |
| 207 |
), |
| 208 |
( |
| 209 |
'foo.html', |
| 210 |
".//table/caption/span[@class='caption-number']", |
| 211 |
'^Table 4 $', |
| 212 |
True, |
| 213 |
), |
| 214 |
( |
| 215 |
'foo.html', |
| 216 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 217 |
'^Listing 1 $', |
| 218 |
True, |
| 219 |
), |
| 220 |
( |
| 221 |
'foo.html', |
| 222 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 223 |
'^Listing 2 $', |
| 224 |
True, |
| 225 |
), |
| 226 |
( |
| 227 |
'foo.html', |
| 228 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 229 |
'^Listing 3 $', |
| 230 |
True, |
| 231 |
), |
| 232 |
( |
| 233 |
'foo.html', |
| 234 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 235 |
'^Listing 4 $', |
| 236 |
True, |
| 237 |
), |
| 238 |
( |
| 239 |
'bar.html', |
| 240 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 241 |
'^Fig. 5 $', |
| 242 |
True, |
| 243 |
), |
| 244 |
( |
| 245 |
'bar.html', |
| 246 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 247 |
'^Fig. 7 $', |
| 248 |
True, |
| 249 |
), |
| 250 |
( |
| 251 |
'bar.html', |
| 252 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 253 |
'^Fig. 8 $', |
| 254 |
True, |
| 255 |
), |
| 256 |
( |
| 257 |
'bar.html', |
| 258 |
".//table/caption/span[@class='caption-number']", |
| 259 |
'^Table 5 $', |
| 260 |
True, |
| 261 |
), |
| 262 |
( |
| 263 |
'bar.html', |
| 264 |
".//table/caption/span[@class='caption-number']", |
| 265 |
'^Table 7 $', |
| 266 |
True, |
| 267 |
), |
| 268 |
( |
| 269 |
'bar.html', |
| 270 |
".//table/caption/span[@class='caption-number']", |
| 271 |
'^Table 8 $', |
| 272 |
True, |
| 273 |
), |
| 274 |
( |
| 275 |
'bar.html', |
| 276 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 277 |
'^Listing 5 $', |
| 278 |
True, |
| 279 |
), |
| 280 |
( |
| 281 |
'bar.html', |
| 282 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 283 |
'^Listing 7 $', |
| 284 |
True, |
| 285 |
), |
| 286 |
( |
| 287 |
'bar.html', |
| 288 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 289 |
'^Listing 8 $', |
| 290 |
True, |
| 291 |
), |
| 292 |
( |
| 293 |
'baz.html', |
| 294 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 295 |
'^Fig. 6 $', |
| 296 |
True, |
| 297 |
), |
| 298 |
( |
| 299 |
'baz.html', |
| 300 |
".//table/caption/span[@class='caption-number']", |
| 301 |
'^Table 6 $', |
| 302 |
True, |
| 303 |
), |
| 304 |
( |
| 305 |
'baz.html', |
| 306 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 307 |
'^Listing 6 $', |
| 308 |
True, |
| 309 |
), |
| 310 |
], |
| 311 |
) |
| 312 |
@pytest.mark.sphinx( |
| 313 |
'html', |
| 314 |
testroot='numfig', |
| 315 |
srcdir='test_numfig_without_numbered_toctree', |
| 316 |
confoverrides={'numfig': True}, |
| 317 |
) |
| 318 |
def test_numfig_without_numbered_toctree( |
| 319 |
app: SphinxTestApp, |
| 320 |
cached_etree_parse: Callable[[Path], ElementTree], |
| 321 |
fname: str, |
| 322 |
path: str, |
| 323 |
check: str | None, |
| 324 |
be_found: bool, |
| 325 |
) -> None: |
| 326 |
# remove :numbered: option |
| 327 |
index = (app.srcdir / 'index.rst').read_text(encoding='utf8') |
| 328 |
index = re.sub(':numbered:.*', '', index) |
| 329 |
(app.srcdir / 'index.rst').write_text(index, encoding='utf8') |
| 330 |
|
| 331 |
if not list(app.outdir.iterdir()): |
| 332 |
app.build() |
| 333 |
check_xpath(cached_etree_parse(app.outdir / fname), fname, path, check, be_found) |
| 334 |
|
| 335 |
|
| 336 |
@pytest.mark.sphinx( |
| 337 |
'html', |
| 338 |
testroot='numfig', |
| 339 |
confoverrides={'numfig': True}, |
| 340 |
) |
| 341 |
@pytest.mark.test_params(shared_result='test_build_html_numfig_on') |
| 342 |
def test_numfig_with_numbered_toctree_warn(app: SphinxTestApp) -> None: |
| 343 |
app.build() |
| 344 |
warnings = app.warning.getvalue() |
| 345 |
assert ( |
| 346 |
'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' |
| 347 |
) not in warnings |
| 348 |
assert ( |
| 349 |
'index.rst:55: WARNING: Failed to create a cross reference. Any number is not assigned: index' |
| 350 |
) in warnings |
| 351 |
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' in warnings |
| 352 |
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings |
| 353 |
|
| 354 |
|
| 355 |
@pytest.mark.parametrize( |
| 356 |
('fname', 'path', 'check', 'be_found'), |
| 357 |
[ |
| 358 |
( |
| 359 |
'index.html', |
| 360 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 361 |
'^Fig. 1 $', |
| 362 |
True, |
| 363 |
), |
| 364 |
( |
| 365 |
'index.html', |
| 366 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 367 |
'^Fig. 2 $', |
| 368 |
True, |
| 369 |
), |
| 370 |
( |
| 371 |
'index.html', |
| 372 |
".//table/caption/span[@class='caption-number']", |
| 373 |
'^Table 1 $', |
| 374 |
True, |
| 375 |
), |
| 376 |
( |
| 377 |
'index.html', |
| 378 |
".//table/caption/span[@class='caption-number']", |
| 379 |
'^Table 2 $', |
| 380 |
True, |
| 381 |
), |
| 382 |
( |
| 383 |
'index.html', |
| 384 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 385 |
'^Listing 1 $', |
| 386 |
True, |
| 387 |
), |
| 388 |
( |
| 389 |
'index.html', |
| 390 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 391 |
'^Listing 2 $', |
| 392 |
True, |
| 393 |
), |
| 394 |
('index.html', './/li/p/a/span', '^Fig. 1$', True), |
| 395 |
('index.html', './/li/p/a/span', '^Figure2.2$', True), |
| 396 |
('index.html', './/li/p/a/span', '^Table 1$', True), |
| 397 |
('index.html', './/li/p/a/span', '^Table:2.2$', True), |
| 398 |
('index.html', './/li/p/a/span', '^Listing 1$', True), |
| 399 |
('index.html', './/li/p/a/span', '^Code-2.2$', True), |
| 400 |
('index.html', './/li/p/a/span', '^Section.1$', True), |
| 401 |
('index.html', './/li/p/a/span', '^Section.2.1$', True), |
| 402 |
('index.html', './/li/p/a/span', '^Fig.1 should be Fig.1$', True), |
| 403 |
('index.html', './/li/p/a/span', '^Sect.1 Foo$', True), |
| 404 |
( |
| 405 |
'foo.html', |
| 406 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 407 |
'^Fig. 1.1 $', |
| 408 |
True, |
| 409 |
), |
| 410 |
( |
| 411 |
'foo.html', |
| 412 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 413 |
'^Fig. 1.2 $', |
| 414 |
True, |
| 415 |
), |
| 416 |
( |
| 417 |
'foo.html', |
| 418 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 419 |
'^Fig. 1.3 $', |
| 420 |
True, |
| 421 |
), |
| 422 |
( |
| 423 |
'foo.html', |
| 424 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 425 |
'^Fig. 1.4 $', |
| 426 |
True, |
| 427 |
), |
| 428 |
( |
| 429 |
'foo.html', |
| 430 |
".//table/caption/span[@class='caption-number']", |
| 431 |
'^Table 1.1 $', |
| 432 |
True, |
| 433 |
), |
| 434 |
( |
| 435 |
'foo.html', |
| 436 |
".//table/caption/span[@class='caption-number']", |
| 437 |
'^Table 1.2 $', |
| 438 |
True, |
| 439 |
), |
| 440 |
( |
| 441 |
'foo.html', |
| 442 |
".//table/caption/span[@class='caption-number']", |
| 443 |
'^Table 1.3 $', |
| 444 |
True, |
| 445 |
), |
| 446 |
( |
| 447 |
'foo.html', |
| 448 |
".//table/caption/span[@class='caption-number']", |
| 449 |
'^Table 1.4 $', |
| 450 |
True, |
| 451 |
), |
| 452 |
( |
| 453 |
'foo.html', |
| 454 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 455 |
'^Listing 1.1 $', |
| 456 |
True, |
| 457 |
), |
| 458 |
( |
| 459 |
'foo.html', |
| 460 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 461 |
'^Listing 1.2 $', |
| 462 |
True, |
| 463 |
), |
| 464 |
( |
| 465 |
'foo.html', |
| 466 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 467 |
'^Listing 1.3 $', |
| 468 |
True, |
| 469 |
), |
| 470 |
( |
| 471 |
'foo.html', |
| 472 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 473 |
'^Listing 1.4 $', |
| 474 |
True, |
| 475 |
), |
| 476 |
( |
| 477 |
'bar.html', |
| 478 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 479 |
'^Fig. 2.1 $', |
| 480 |
True, |
| 481 |
), |
| 482 |
( |
| 483 |
'bar.html', |
| 484 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 485 |
'^Fig. 2.3 $', |
| 486 |
True, |
| 487 |
), |
| 488 |
( |
| 489 |
'bar.html', |
| 490 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 491 |
'^Fig. 2.4 $', |
| 492 |
True, |
| 493 |
), |
| 494 |
( |
| 495 |
'bar.html', |
| 496 |
".//table/caption/span[@class='caption-number']", |
| 497 |
'^Table 2.1 $', |
| 498 |
True, |
| 499 |
), |
| 500 |
( |
| 501 |
'bar.html', |
| 502 |
".//table/caption/span[@class='caption-number']", |
| 503 |
'^Table 2.3 $', |
| 504 |
True, |
| 505 |
), |
| 506 |
( |
| 507 |
'bar.html', |
| 508 |
".//table/caption/span[@class='caption-number']", |
| 509 |
'^Table 2.4 $', |
| 510 |
True, |
| 511 |
), |
| 512 |
( |
| 513 |
'bar.html', |
| 514 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 515 |
'^Listing 2.1 $', |
| 516 |
True, |
| 517 |
), |
| 518 |
( |
| 519 |
'bar.html', |
| 520 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 521 |
'^Listing 2.3 $', |
| 522 |
True, |
| 523 |
), |
| 524 |
( |
| 525 |
'bar.html', |
| 526 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 527 |
'^Listing 2.4 $', |
| 528 |
True, |
| 529 |
), |
| 530 |
( |
| 531 |
'baz.html', |
| 532 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 533 |
'^Fig. 2.2 $', |
| 534 |
True, |
| 535 |
), |
| 536 |
( |
| 537 |
'baz.html', |
| 538 |
".//table/caption/span[@class='caption-number']", |
| 539 |
'^Table 2.2 $', |
| 540 |
True, |
| 541 |
), |
| 542 |
( |
| 543 |
'baz.html', |
| 544 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 545 |
'^Listing 2.2 $', |
| 546 |
True, |
| 547 |
), |
| 548 |
], |
| 549 |
) |
| 550 |
@pytest.mark.sphinx( |
| 551 |
'html', |
| 552 |
testroot='numfig', |
| 553 |
confoverrides={'numfig': True}, |
| 554 |
) |
| 555 |
@pytest.mark.test_params(shared_result='test_build_html_numfig_on') |
| 556 |
def test_numfig_with_numbered_toctree( |
| 557 |
app: SphinxTestApp, |
| 558 |
cached_etree_parse: Callable[[Path], ElementTree], |
| 559 |
fname: str, |
| 560 |
path: str, |
| 561 |
check: str | None, |
| 562 |
be_found: bool, |
| 563 |
) -> None: |
| 564 |
app.build() |
| 565 |
check_xpath(cached_etree_parse(app.outdir / fname), fname, path, check, be_found) |
| 566 |
|
| 567 |
|
| 568 |
@pytest.mark.sphinx( |
| 569 |
'html', |
| 570 |
testroot='numfig', |
| 571 |
confoverrides={ |
| 572 |
'numfig': True, |
| 573 |
'numfig_format': { |
| 574 |
'figure': 'Figure:%s', |
| 575 |
'table': 'Tab_%s', |
| 576 |
'code-block': 'Code-%s', |
| 577 |
'section': 'SECTION-%s', |
| 578 |
}, |
| 579 |
}, |
| 580 |
) |
| 581 |
@pytest.mark.test_params(shared_result='test_build_html_numfig_format_warn') |
| 582 |
def test_numfig_with_prefix_warn(app: SphinxTestApp) -> None: |
| 583 |
app.build() |
| 584 |
warnings = app.warning.getvalue() |
| 585 |
assert ( |
| 586 |
'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' |
| 587 |
) not in warnings |
| 588 |
assert ( |
| 589 |
'index.rst:55: WARNING: Failed to create a cross reference. Any number is not assigned: index' |
| 590 |
) in warnings |
| 591 |
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' in warnings |
| 592 |
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings |
| 593 |
|
| 594 |
|
| 595 |
@pytest.mark.parametrize( |
| 596 |
('fname', 'path', 'check', 'be_found'), |
| 597 |
[ |
| 598 |
( |
| 599 |
'index.html', |
| 600 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 601 |
'^Figure:1 $', |
| 602 |
True, |
| 603 |
), |
| 604 |
( |
| 605 |
'index.html', |
| 606 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 607 |
'^Figure:2 $', |
| 608 |
True, |
| 609 |
), |
| 610 |
( |
| 611 |
'index.html', |
| 612 |
".//table/caption/span[@class='caption-number']", |
| 613 |
'^Tab_1 $', |
| 614 |
True, |
| 615 |
), |
| 616 |
( |
| 617 |
'index.html', |
| 618 |
".//table/caption/span[@class='caption-number']", |
| 619 |
'^Tab_2 $', |
| 620 |
True, |
| 621 |
), |
| 622 |
( |
| 623 |
'index.html', |
| 624 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 625 |
'^Code-1 $', |
| 626 |
True, |
| 627 |
), |
| 628 |
( |
| 629 |
'index.html', |
| 630 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 631 |
'^Code-2 $', |
| 632 |
True, |
| 633 |
), |
| 634 |
('index.html', './/li/p/a/span', '^Figure:1$', True), |
| 635 |
('index.html', './/li/p/a/span', '^Figure2.2$', True), |
| 636 |
('index.html', './/li/p/a/span', '^Tab_1$', True), |
| 637 |
('index.html', './/li/p/a/span', '^Table:2.2$', True), |
| 638 |
('index.html', './/li/p/a/span', '^Code-1$', True), |
| 639 |
('index.html', './/li/p/a/span', '^Code-2.2$', True), |
| 640 |
('index.html', './/li/p/a/span', '^SECTION-1$', True), |
| 641 |
('index.html', './/li/p/a/span', '^SECTION-2.1$', True), |
| 642 |
('index.html', './/li/p/a/span', '^Fig.1 should be Fig.1$', True), |
| 643 |
('index.html', './/li/p/a/span', '^Sect.1 Foo$', True), |
| 644 |
( |
| 645 |
'foo.html', |
| 646 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 647 |
'^Figure:1.1 $', |
| 648 |
True, |
| 649 |
), |
| 650 |
( |
| 651 |
'foo.html', |
| 652 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 653 |
'^Figure:1.2 $', |
| 654 |
True, |
| 655 |
), |
| 656 |
( |
| 657 |
'foo.html', |
| 658 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 659 |
'^Figure:1.3 $', |
| 660 |
True, |
| 661 |
), |
| 662 |
( |
| 663 |
'foo.html', |
| 664 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 665 |
'^Figure:1.4 $', |
| 666 |
True, |
| 667 |
), |
| 668 |
( |
| 669 |
'foo.html', |
| 670 |
".//table/caption/span[@class='caption-number']", |
| 671 |
'^Tab_1.1 $', |
| 672 |
True, |
| 673 |
), |
| 674 |
( |
| 675 |
'foo.html', |
| 676 |
".//table/caption/span[@class='caption-number']", |
| 677 |
'^Tab_1.2 $', |
| 678 |
True, |
| 679 |
), |
| 680 |
( |
| 681 |
'foo.html', |
| 682 |
".//table/caption/span[@class='caption-number']", |
| 683 |
'^Tab_1.3 $', |
| 684 |
True, |
| 685 |
), |
| 686 |
( |
| 687 |
'foo.html', |
| 688 |
".//table/caption/span[@class='caption-number']", |
| 689 |
'^Tab_1.4 $', |
| 690 |
True, |
| 691 |
), |
| 692 |
( |
| 693 |
'foo.html', |
| 694 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 695 |
'^Code-1.1 $', |
| 696 |
True, |
| 697 |
), |
| 698 |
( |
| 699 |
'foo.html', |
| 700 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 701 |
'^Code-1.2 $', |
| 702 |
True, |
| 703 |
), |
| 704 |
( |
| 705 |
'foo.html', |
| 706 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 707 |
'^Code-1.3 $', |
| 708 |
True, |
| 709 |
), |
| 710 |
( |
| 711 |
'foo.html', |
| 712 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 713 |
'^Code-1.4 $', |
| 714 |
True, |
| 715 |
), |
| 716 |
( |
| 717 |
'bar.html', |
| 718 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 719 |
'^Figure:2.1 $', |
| 720 |
True, |
| 721 |
), |
| 722 |
( |
| 723 |
'bar.html', |
| 724 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 725 |
'^Figure:2.3 $', |
| 726 |
True, |
| 727 |
), |
| 728 |
( |
| 729 |
'bar.html', |
| 730 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 731 |
'^Figure:2.4 $', |
| 732 |
True, |
| 733 |
), |
| 734 |
( |
| 735 |
'bar.html', |
| 736 |
".//table/caption/span[@class='caption-number']", |
| 737 |
'^Tab_2.1 $', |
| 738 |
True, |
| 739 |
), |
| 740 |
( |
| 741 |
'bar.html', |
| 742 |
".//table/caption/span[@class='caption-number']", |
| 743 |
'^Tab_2.3 $', |
| 744 |
True, |
| 745 |
), |
| 746 |
( |
| 747 |
'bar.html', |
| 748 |
".//table/caption/span[@class='caption-number']", |
| 749 |
'^Tab_2.4 $', |
| 750 |
True, |
| 751 |
), |
| 752 |
( |
| 753 |
'bar.html', |
| 754 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 755 |
'^Code-2.1 $', |
| 756 |
True, |
| 757 |
), |
| 758 |
( |
| 759 |
'bar.html', |
| 760 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 761 |
'^Code-2.3 $', |
| 762 |
True, |
| 763 |
), |
| 764 |
( |
| 765 |
'bar.html', |
| 766 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 767 |
'^Code-2.4 $', |
| 768 |
True, |
| 769 |
), |
| 770 |
( |
| 771 |
'baz.html', |
| 772 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 773 |
'^Figure:2.2 $', |
| 774 |
True, |
| 775 |
), |
| 776 |
( |
| 777 |
'baz.html', |
| 778 |
".//table/caption/span[@class='caption-number']", |
| 779 |
'^Tab_2.2 $', |
| 780 |
True, |
| 781 |
), |
| 782 |
( |
| 783 |
'baz.html', |
| 784 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 785 |
'^Code-2.2 $', |
| 786 |
True, |
| 787 |
), |
| 788 |
], |
| 789 |
) |
| 790 |
@pytest.mark.sphinx( |
| 791 |
'html', |
| 792 |
testroot='numfig', |
| 793 |
confoverrides={ |
| 794 |
'numfig': True, |
| 795 |
'numfig_format': { |
| 796 |
'figure': 'Figure:%s', |
| 797 |
'table': 'Tab_%s', |
| 798 |
'code-block': 'Code-%s', |
| 799 |
'section': 'SECTION-%s', |
| 800 |
}, |
| 801 |
}, |
| 802 |
) |
| 803 |
@pytest.mark.test_params(shared_result='test_build_html_numfig_format_warn') |
| 804 |
def test_numfig_with_prefix( |
| 805 |
app: SphinxTestApp, |
| 806 |
cached_etree_parse: Callable[[Path], ElementTree], |
| 807 |
fname: str, |
| 808 |
path: str, |
| 809 |
check: str | None, |
| 810 |
be_found: bool, |
| 811 |
) -> None: |
| 812 |
app.build() |
| 813 |
check_xpath(cached_etree_parse(app.outdir / fname), fname, path, check, be_found) |
| 814 |
|
| 815 |
|
| 816 |
@pytest.mark.sphinx( |
| 817 |
'html', |
| 818 |
testroot='numfig', |
| 819 |
confoverrides={'numfig': True, 'numfig_secnum_depth': 2}, |
| 820 |
) |
| 821 |
@pytest.mark.test_params(shared_result='test_build_html_numfig_depth_2') |
| 822 |
def test_numfig_with_secnum_depth_warn(app: SphinxTestApp) -> None: |
| 823 |
app.build() |
| 824 |
warnings = app.warning.getvalue() |
| 825 |
assert ( |
| 826 |
'index.rst:47: WARNING: numfig is disabled. :numref: is ignored.' |
| 827 |
) not in warnings |
| 828 |
assert ( |
| 829 |
'index.rst:55: WARNING: Failed to create a cross reference. Any number is not assigned: index' |
| 830 |
) in warnings |
| 831 |
assert 'index.rst:56: WARNING: invalid numfig_format: invalid' in warnings |
| 832 |
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings |
| 833 |
|
| 834 |
|
| 835 |
@pytest.mark.parametrize( |
| 836 |
('fname', 'path', 'check', 'be_found'), |
| 837 |
[ |
| 838 |
( |
| 839 |
'index.html', |
| 840 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 841 |
'^Fig. 1 $', |
| 842 |
True, |
| 843 |
), |
| 844 |
( |
| 845 |
'index.html', |
| 846 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 847 |
'^Fig. 2 $', |
| 848 |
True, |
| 849 |
), |
| 850 |
( |
| 851 |
'index.html', |
| 852 |
".//table/caption/span[@class='caption-number']", |
| 853 |
'^Table 1 $', |
| 854 |
True, |
| 855 |
), |
| 856 |
( |
| 857 |
'index.html', |
| 858 |
".//table/caption/span[@class='caption-number']", |
| 859 |
'^Table 2 $', |
| 860 |
True, |
| 861 |
), |
| 862 |
( |
| 863 |
'index.html', |
| 864 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 865 |
'^Listing 1 $', |
| 866 |
True, |
| 867 |
), |
| 868 |
( |
| 869 |
'index.html', |
| 870 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 871 |
'^Listing 2 $', |
| 872 |
True, |
| 873 |
), |
| 874 |
('index.html', './/li/p/a/span', '^Fig. 1$', True), |
| 875 |
('index.html', './/li/p/a/span', '^Figure2.1.2$', True), |
| 876 |
('index.html', './/li/p/a/span', '^Table 1$', True), |
| 877 |
('index.html', './/li/p/a/span', '^Table:2.1.2$', True), |
| 878 |
('index.html', './/li/p/a/span', '^Listing 1$', True), |
| 879 |
('index.html', './/li/p/a/span', '^Code-2.1.2$', True), |
| 880 |
('index.html', './/li/p/a/span', '^Section.1$', True), |
| 881 |
('index.html', './/li/p/a/span', '^Section.2.1$', True), |
| 882 |
('index.html', './/li/p/a/span', '^Fig.1 should be Fig.1$', True), |
| 883 |
('index.html', './/li/p/a/span', '^Sect.1 Foo$', True), |
| 884 |
( |
| 885 |
'foo.html', |
| 886 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 887 |
'^Fig. 1.1 $', |
| 888 |
True, |
| 889 |
), |
| 890 |
( |
| 891 |
'foo.html', |
| 892 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 893 |
'^Fig. 1.1.1 $', |
| 894 |
True, |
| 895 |
), |
| 896 |
( |
| 897 |
'foo.html', |
| 898 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 899 |
'^Fig. 1.1.2 $', |
| 900 |
True, |
| 901 |
), |
| 902 |
( |
| 903 |
'foo.html', |
| 904 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 905 |
'^Fig. 1.2.1 $', |
| 906 |
True, |
| 907 |
), |
| 908 |
( |
| 909 |
'foo.html', |
| 910 |
".//table/caption/span[@class='caption-number']", |
| 911 |
'^Table 1.1 $', |
| 912 |
True, |
| 913 |
), |
| 914 |
( |
| 915 |
'foo.html', |
| 916 |
".//table/caption/span[@class='caption-number']", |
| 917 |
'^Table 1.1.1 $', |
| 918 |
True, |
| 919 |
), |
| 920 |
( |
| 921 |
'foo.html', |
| 922 |
".//table/caption/span[@class='caption-number']", |
| 923 |
'^Table 1.1.2 $', |
| 924 |
True, |
| 925 |
), |
| 926 |
( |
| 927 |
'foo.html', |
| 928 |
".//table/caption/span[@class='caption-number']", |
| 929 |
'^Table 1.2.1 $', |
| 930 |
True, |
| 931 |
), |
| 932 |
( |
| 933 |
'foo.html', |
| 934 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 935 |
'^Listing 1.1 $', |
| 936 |
True, |
| 937 |
), |
| 938 |
( |
| 939 |
'foo.html', |
| 940 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 941 |
'^Listing 1.1.1 $', |
| 942 |
True, |
| 943 |
), |
| 944 |
( |
| 945 |
'foo.html', |
| 946 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 947 |
'^Listing 1.1.2 $', |
| 948 |
True, |
| 949 |
), |
| 950 |
( |
| 951 |
'foo.html', |
| 952 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 953 |
'^Listing 1.2.1 $', |
| 954 |
True, |
| 955 |
), |
| 956 |
( |
| 957 |
'bar.html', |
| 958 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 959 |
'^Fig. 2.1.1 $', |
| 960 |
True, |
| 961 |
), |
| 962 |
( |
| 963 |
'bar.html', |
| 964 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 965 |
'^Fig. 2.1.3 $', |
| 966 |
True, |
| 967 |
), |
| 968 |
( |
| 969 |
'bar.html', |
| 970 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 971 |
'^Fig. 2.2.1 $', |
| 972 |
True, |
| 973 |
), |
| 974 |
( |
| 975 |
'bar.html', |
| 976 |
".//table/caption/span[@class='caption-number']", |
| 977 |
'^Table 2.1.1 $', |
| 978 |
True, |
| 979 |
), |
| 980 |
( |
| 981 |
'bar.html', |
| 982 |
".//table/caption/span[@class='caption-number']", |
| 983 |
'^Table 2.1.3 $', |
| 984 |
True, |
| 985 |
), |
| 986 |
( |
| 987 |
'bar.html', |
| 988 |
".//table/caption/span[@class='caption-number']", |
| 989 |
'^Table 2.2.1 $', |
| 990 |
True, |
| 991 |
), |
| 992 |
( |
| 993 |
'bar.html', |
| 994 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 995 |
'^Listing 2.1.1 $', |
| 996 |
True, |
| 997 |
), |
| 998 |
( |
| 999 |
'bar.html', |
| 1000 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1001 |
'^Listing 2.1.3 $', |
| 1002 |
True, |
| 1003 |
), |
| 1004 |
( |
| 1005 |
'bar.html', |
| 1006 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1007 |
'^Listing 2.2.1 $', |
| 1008 |
True, |
| 1009 |
), |
| 1010 |
( |
| 1011 |
'baz.html', |
| 1012 |
FIGURE_CAPTION + "/span[@class='caption-number']", |
| 1013 |
'^Fig. 2.1.2 $', |
| 1014 |
True, |
| 1015 |
), |
| 1016 |
( |
| 1017 |
'baz.html', |
| 1018 |
".//table/caption/span[@class='caption-number']", |
| 1019 |
'^Table 2.1.2 $', |
| 1020 |
True, |
| 1021 |
), |
| 1022 |
( |
| 1023 |
'baz.html', |
| 1024 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1025 |
'^Listing 2.1.2 $', |
| 1026 |
True, |
| 1027 |
), |
| 1028 |
], |
| 1029 |
) |
| 1030 |
@pytest.mark.sphinx( |
| 1031 |
'html', |
| 1032 |
testroot='numfig', |
| 1033 |
confoverrides={'numfig': True, 'numfig_secnum_depth': 2}, |
| 1034 |
) |
| 1035 |
@pytest.mark.test_params(shared_result='test_build_html_numfig_depth_2') |
| 1036 |
def test_numfig_with_secnum_depth( |
| 1037 |
app: SphinxTestApp, |
| 1038 |
cached_etree_parse: Callable[[Path], ElementTree], |
| 1039 |
fname: str, |
| 1040 |
path: str, |
| 1041 |
check: str | None, |
| 1042 |
be_found: bool, |
| 1043 |
) -> None: |
| 1044 |
app.build() |
| 1045 |
check_xpath(cached_etree_parse(app.outdir / fname), fname, path, check, be_found) |
| 1046 |
|
| 1047 |
|
| 1048 |
@pytest.mark.parametrize( |
| 1049 |
'expect', |
| 1050 |
[ |
| 1051 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1 $', True), |
| 1052 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2 $', True), |
| 1053 |
(".//table/caption/span[@class='caption-number']", '^Table 1 $', True), |
| 1054 |
(".//table/caption/span[@class='caption-number']", '^Table 2 $', True), |
| 1055 |
( |
| 1056 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1057 |
'^Listing 1 $', |
| 1058 |
True, |
| 1059 |
), |
| 1060 |
( |
| 1061 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1062 |
'^Listing 2 $', |
| 1063 |
True, |
| 1064 |
), |
| 1065 |
('.//li/p/a/span', '^Fig. 1$', True), |
| 1066 |
('.//li/p/a/span', '^Figure2.2$', True), |
| 1067 |
('.//li/p/a/span', '^Table 1$', True), |
| 1068 |
('.//li/p/a/span', '^Table:2.2$', True), |
| 1069 |
('.//li/p/a/span', '^Listing 1$', True), |
| 1070 |
('.//li/p/a/span', '^Code-2.2$', True), |
| 1071 |
('.//li/p/a/span', '^Section.1$', True), |
| 1072 |
('.//li/p/a/span', '^Section.2.1$', True), |
| 1073 |
('.//li/p/a/span', '^Fig.1 should be Fig.1$', True), |
| 1074 |
('.//li/p/a/span', '^Sect.1 Foo$', True), |
| 1075 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1.1 $', True), |
| 1076 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1.2 $', True), |
| 1077 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1.3 $', True), |
| 1078 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1.4 $', True), |
| 1079 |
(".//table/caption/span[@class='caption-number']", '^Table 1.1 $', True), |
| 1080 |
(".//table/caption/span[@class='caption-number']", '^Table 1.2 $', True), |
| 1081 |
(".//table/caption/span[@class='caption-number']", '^Table 1.3 $', True), |
| 1082 |
(".//table/caption/span[@class='caption-number']", '^Table 1.4 $', True), |
| 1083 |
( |
| 1084 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1085 |
'^Listing 1.1 $', |
| 1086 |
True, |
| 1087 |
), |
| 1088 |
( |
| 1089 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1090 |
'^Listing 1.2 $', |
| 1091 |
True, |
| 1092 |
), |
| 1093 |
( |
| 1094 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1095 |
'^Listing 1.3 $', |
| 1096 |
True, |
| 1097 |
), |
| 1098 |
( |
| 1099 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1100 |
'^Listing 1.4 $', |
| 1101 |
True, |
| 1102 |
), |
| 1103 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2.1 $', True), |
| 1104 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2.3 $', True), |
| 1105 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2.4 $', True), |
| 1106 |
(".//table/caption/span[@class='caption-number']", '^Table 2.1 $', True), |
| 1107 |
(".//table/caption/span[@class='caption-number']", '^Table 2.3 $', True), |
| 1108 |
(".//table/caption/span[@class='caption-number']", '^Table 2.4 $', True), |
| 1109 |
( |
| 1110 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1111 |
'^Listing 2.1 $', |
| 1112 |
True, |
| 1113 |
), |
| 1114 |
( |
| 1115 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1116 |
'^Listing 2.3 $', |
| 1117 |
True, |
| 1118 |
), |
| 1119 |
( |
| 1120 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1121 |
'^Listing 2.4 $', |
| 1122 |
True, |
| 1123 |
), |
| 1124 |
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2.2 $', True), |
| 1125 |
(".//table/caption/span[@class='caption-number']", '^Table 2.2 $', True), |
| 1126 |
( |
| 1127 |
".//div[@class='code-block-caption']/span[@class='caption-number']", |
| 1128 |
'^Listing 2.2 $', |
| 1129 |
True, |
| 1130 |
), |
| 1131 |
], |
| 1132 |
) |
| 1133 |
@pytest.mark.sphinx( |
| 1134 |
'singlehtml', |
| 1135 |
testroot='numfig', |
| 1136 |
confoverrides={'numfig': True}, |
| 1137 |
) |
| 1138 |
@pytest.mark.test_params(shared_result='test_build_html_numfig_on') |
| 1139 |
def test_numfig_with_singlehtml( |
| 1140 |
app: SphinxTestApp, |
| 1141 |
cached_etree_parse: Callable[[Path], ElementTree], |
| 1142 |
expect: tuple[str, str, bool], |
| 1143 |
) -> None: |
| 1144 |
app.build() |
| 1145 |
check_xpath(cached_etree_parse(app.outdir / 'index.html'), 'index.html', *expect) |