Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
"""Test the BuildEnvironment class."""
|
2024-08-11 08:58:56 -05:00
|
|
|
|
2019-05-31 11:19:44 -05:00
|
|
|
import shutil
|
2023-07-27 18:39:12 -05:00
|
|
|
from pathlib import Path
|
2020-11-11 05:00:27 -06:00
|
|
|
|
2017-05-07 02:46:44 -05:00
|
|
|
import pytest
|
2014-09-21 10:17:02 -05:00
|
|
|
|
2008-12-23 13:04:45 -06:00
|
|
|
from sphinx.builders.html import StandaloneHTMLBuilder
|
|
|
|
from sphinx.builders.latex import LaTeXBuilder
|
2024-10-08 00:25:49 -05:00
|
|
|
from sphinx.config import Config
|
2024-08-10 18:19:50 -05:00
|
|
|
from sphinx.environment import (
|
|
|
|
CONFIG_CHANGED,
|
|
|
|
CONFIG_EXTENSIONS_CHANGED,
|
|
|
|
CONFIG_NEW,
|
|
|
|
CONFIG_OK,
|
2024-10-08 00:25:49 -05:00
|
|
|
_differing_config_keys,
|
2024-08-10 18:19:50 -05:00
|
|
|
)
|
2024-10-08 00:25:49 -05:00
|
|
|
from sphinx.util.console import strip_colors
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
|
|
|
|
2019-06-29 08:05:25 -05:00
|
|
|
@pytest.mark.sphinx('dummy', testroot='basic')
|
|
|
|
def test_config_status(make_app, app_params):
|
|
|
|
args, kwargs = app_params
|
|
|
|
|
|
|
|
# clean build
|
|
|
|
app1 = make_app(*args, freshenv=True, **kwargs)
|
|
|
|
assert app1.env.config_status == CONFIG_NEW
|
|
|
|
app1.build()
|
2024-10-08 00:25:49 -05:00
|
|
|
output = strip_colors(app1.status.getvalue())
|
|
|
|
# assert 'The configuration has changed' not in output
|
|
|
|
assert '[new config] 1 added' in output
|
2019-06-29 08:05:25 -05:00
|
|
|
|
|
|
|
# incremental build (no config changed)
|
|
|
|
app2 = make_app(*args, **kwargs)
|
|
|
|
assert app2.env.config_status == CONFIG_OK
|
2019-05-31 11:19:44 -05:00
|
|
|
app2.build()
|
2024-10-08 00:25:49 -05:00
|
|
|
output = strip_colors(app2.status.getvalue())
|
|
|
|
assert 'The configuration has changed' not in output
|
|
|
|
assert '0 added, 0 changed, 0 removed' in output
|
2019-06-29 08:05:25 -05:00
|
|
|
|
|
|
|
# incremental build (config entry changed)
|
2020-11-24 09:50:36 -06:00
|
|
|
app3 = make_app(*args, confoverrides={'root_doc': 'indexx'}, **kwargs)
|
2024-10-25 16:41:08 -05:00
|
|
|
fname = app3.srcdir / 'index.rst'
|
2024-11-02 16:39:18 -05:00
|
|
|
other_fname = app3.srcdir / 'indexx.rst'
|
2024-10-25 16:41:08 -05:00
|
|
|
assert fname.is_file()
|
2024-11-02 16:39:18 -05:00
|
|
|
shutil.move(fname, other_fname)
|
2019-06-29 08:05:25 -05:00
|
|
|
assert app3.env.config_status == CONFIG_CHANGED
|
2019-05-31 11:19:44 -05:00
|
|
|
app3.build()
|
2024-11-02 16:39:18 -05:00
|
|
|
shutil.move(other_fname, fname)
|
2024-10-08 00:25:49 -05:00
|
|
|
output = strip_colors(app3.status.getvalue())
|
|
|
|
assert 'The configuration has changed' in output
|
|
|
|
assert "[config changed ('master_doc')] 1 added," in output
|
2019-06-29 08:05:25 -05:00
|
|
|
|
|
|
|
# incremental build (extension changed)
|
2024-08-11 08:58:56 -05:00
|
|
|
app4 = make_app(
|
|
|
|
*args, confoverrides={'extensions': ['sphinx.ext.autodoc']}, **kwargs
|
|
|
|
)
|
2019-06-29 08:05:25 -05:00
|
|
|
assert app4.env.config_status == CONFIG_EXTENSIONS_CHANGED
|
2019-05-31 11:19:44 -05:00
|
|
|
app4.build()
|
|
|
|
want_str = "[extensions changed ('sphinx.ext.autodoc')] 1 added"
|
2024-10-08 00:25:49 -05:00
|
|
|
output = strip_colors(app4.status.getvalue())
|
|
|
|
assert 'The configuration has changed' not in output
|
|
|
|
assert want_str in output
|
2019-06-29 08:05:25 -05:00
|
|
|
|
|
|
|
|
2024-08-12 16:34:03 -05:00
|
|
|
@pytest.mark.sphinx('dummy', testroot='root')
|
2018-02-23 10:16:27 -06:00
|
|
|
def test_images(app):
|
|
|
|
app.build()
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2018-02-23 10:16:27 -06:00
|
|
|
tree = app.env.get_doctree('images')
|
2022-06-16 13:50:01 -05:00
|
|
|
htmlbuilder = StandaloneHTMLBuilder(app, app.env)
|
2017-03-19 09:16:37 -05:00
|
|
|
htmlbuilder.init()
|
2012-07-29 12:27:28 -05:00
|
|
|
htmlbuilder.imgpath = 'dummy'
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
htmlbuilder.post_process_images(tree)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert set(htmlbuilder.images.keys()) == {
|
|
|
|
'subdir/img.png',
|
|
|
|
'img.png',
|
|
|
|
'subdir/simg.png',
|
|
|
|
'svgimg.svg',
|
|
|
|
'img.foo.png',
|
|
|
|
}
|
|
|
|
assert set(htmlbuilder.images.values()) == {
|
|
|
|
'img.png',
|
|
|
|
'img1.png',
|
|
|
|
'simg.png',
|
|
|
|
'svgimg.svg',
|
|
|
|
'img.foo.png',
|
|
|
|
}
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2022-06-16 13:50:01 -05:00
|
|
|
latexbuilder = LaTeXBuilder(app, app.env)
|
2017-03-19 09:16:37 -05:00
|
|
|
latexbuilder.init()
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
latexbuilder.post_process_images(tree)
|
2024-08-11 08:58:56 -05:00
|
|
|
assert set(latexbuilder.images.keys()) == {
|
|
|
|
'subdir/img.png',
|
|
|
|
'subdir/simg.png',
|
|
|
|
'img.png',
|
|
|
|
'img.pdf',
|
|
|
|
'svgimg.pdf',
|
|
|
|
'img.foo.png',
|
|
|
|
}
|
|
|
|
assert set(latexbuilder.images.values()) == {
|
|
|
|
'img.pdf',
|
|
|
|
'img.png',
|
|
|
|
'img1.png',
|
|
|
|
'simg.png',
|
|
|
|
'svgimg.pdf',
|
|
|
|
'img.foo.png',
|
|
|
|
}
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
|
2024-08-12 16:34:03 -05:00
|
|
|
@pytest.mark.sphinx('dummy', testroot='root')
|
2018-02-23 10:16:27 -06:00
|
|
|
def test_object_inventory(app):
|
|
|
|
app.build()
|
|
|
|
refs = app.env.domaindata['py']['objects']
|
2008-10-18 12:57:35 -05:00
|
|
|
|
|
|
|
assert 'func_without_module' in refs
|
2024-08-11 08:58:56 -05:00
|
|
|
assert refs['func_without_module'] == (
|
|
|
|
'objects',
|
|
|
|
'func_without_module',
|
|
|
|
'function',
|
|
|
|
False,
|
|
|
|
)
|
2008-10-18 12:57:35 -05:00
|
|
|
assert 'func_without_module2' in refs
|
|
|
|
assert 'mod.func_in_module' in refs
|
|
|
|
assert 'mod.Cls' in refs
|
|
|
|
assert 'mod.Cls.meth1' in refs
|
|
|
|
assert 'mod.Cls.meth2' in refs
|
|
|
|
assert 'mod.Cls.meths' in refs
|
|
|
|
|
|
|
|
assert 'mod.Error' not in refs
|
|
|
|
assert 'errmod.Error' in refs
|
|
|
|
|
|
|
|
assert 'func_in_module' not in refs
|
|
|
|
assert 'func_noindex' not in refs
|
|
|
|
|
2024-08-11 08:58:56 -05:00
|
|
|
assert app.env.domaindata['py']['modules']['mod'] == (
|
|
|
|
'objects',
|
|
|
|
'module-mod',
|
|
|
|
'Module synopsis.',
|
|
|
|
'UNIX',
|
|
|
|
False,
|
|
|
|
)
|
2009-07-13 14:31:05 -05:00
|
|
|
|
2024-09-17 21:50:27 -05:00
|
|
|
assert app.env.domains.python_domain.data is app.env.domaindata['py']
|
|
|
|
assert app.env.domains.c_domain.data is app.env.domaindata['c']
|
2018-01-18 07:20:48 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('dummy', testroot='basic')
|
|
|
|
def test_env_relfn2path(app):
|
|
|
|
# relative filename and root document
|
|
|
|
relfn, absfn = app.env.relfn2path('logo.jpg', 'index')
|
|
|
|
assert relfn == 'logo.jpg'
|
2023-07-27 18:39:12 -05:00
|
|
|
assert absfn == str(app.srcdir / 'logo.jpg')
|
2018-01-18 07:20:48 -06:00
|
|
|
|
|
|
|
# absolute filename and root document
|
|
|
|
relfn, absfn = app.env.relfn2path('/logo.jpg', 'index')
|
|
|
|
assert relfn == 'logo.jpg'
|
2023-07-27 18:39:12 -05:00
|
|
|
assert absfn == str(app.srcdir / 'logo.jpg')
|
2018-01-18 07:20:48 -06:00
|
|
|
|
|
|
|
# relative filename and a document in subdir
|
|
|
|
relfn, absfn = app.env.relfn2path('logo.jpg', 'subdir/index')
|
2023-07-27 18:39:12 -05:00
|
|
|
assert Path(relfn) == Path('subdir/logo.jpg')
|
|
|
|
assert absfn == str(app.srcdir / 'subdir' / 'logo.jpg')
|
2018-01-18 07:20:48 -06:00
|
|
|
|
|
|
|
# absolute filename and a document in subdir
|
|
|
|
relfn, absfn = app.env.relfn2path('/logo.jpg', 'subdir/index')
|
|
|
|
assert relfn == 'logo.jpg'
|
2023-07-27 18:39:12 -05:00
|
|
|
assert absfn == str(app.srcdir / 'logo.jpg')
|
2018-01-18 07:20:48 -06:00
|
|
|
|
|
|
|
# relative filename having subdir
|
|
|
|
relfn, absfn = app.env.relfn2path('images/logo.jpg', 'index')
|
|
|
|
assert relfn == 'images/logo.jpg'
|
2023-07-27 18:39:12 -05:00
|
|
|
assert absfn == str(app.srcdir / 'images' / 'logo.jpg')
|
2018-01-18 07:20:48 -06:00
|
|
|
|
|
|
|
# relative path traversal
|
|
|
|
relfn, absfn = app.env.relfn2path('../logo.jpg', 'index')
|
|
|
|
assert relfn == '../logo.jpg'
|
2023-07-27 18:39:12 -05:00
|
|
|
assert absfn == str(app.srcdir.parent / 'logo.jpg')
|
2018-01-18 07:20:48 -06:00
|
|
|
|
2021-01-17 09:00:32 -06:00
|
|
|
# relative path traversal
|
|
|
|
relfn, absfn = app.env.relfn2path('subdir/../logo.jpg', 'index')
|
|
|
|
assert relfn == 'logo.jpg'
|
2023-07-27 18:39:12 -05:00
|
|
|
assert absfn == str(app.srcdir / 'logo.jpg')
|
2021-01-17 09:00:32 -06:00
|
|
|
|
2018-01-18 07:20:48 -06:00
|
|
|
# omit docname (w/ current docname)
|
|
|
|
app.env.temp_data['docname'] = 'subdir/document'
|
|
|
|
relfn, absfn = app.env.relfn2path('images/logo.jpg')
|
2023-07-27 18:39:12 -05:00
|
|
|
assert Path(relfn) == Path('subdir/images/logo.jpg')
|
|
|
|
assert absfn == str(app.srcdir / 'subdir' / 'images' / 'logo.jpg')
|
2018-01-18 07:20:48 -06:00
|
|
|
|
|
|
|
# omit docname (w/o current docname)
|
|
|
|
app.env.temp_data.clear()
|
|
|
|
with pytest.raises(KeyError):
|
|
|
|
app.env.relfn2path('images/logo.jpg')
|
2024-10-08 00:25:49 -05:00
|
|
|
|
|
|
|
|
|
|
|
def test_differing_config_keys():
|
|
|
|
diff = _differing_config_keys
|
|
|
|
|
|
|
|
old = Config({'project': 'old'})
|
|
|
|
new = Config({'project': 'new'})
|
|
|
|
assert diff(old, new) == frozenset({'project'})
|
|
|
|
|
|
|
|
old = Config({'project': 'project', 'release': 'release'})
|
|
|
|
new = Config({'project': 'project', 'version': 'version'})
|
|
|
|
assert diff(old, new) == frozenset({'release', 'version'})
|
|
|
|
|
|
|
|
old = Config({'project': 'project', 'release': 'release'})
|
|
|
|
new = Config({'project': 'project'})
|
|
|
|
assert diff(old, new) == frozenset({'release'})
|
|
|
|
|
|
|
|
old = Config({'project': 'project'})
|
|
|
|
new = Config({'project': 'project', 'version': 'version'})
|
|
|
|
assert diff(old, new) == frozenset({'version'})
|
|
|
|
|
|
|
|
old = Config({'project': 'project', 'release': 'release', 'version': 'version'})
|
|
|
|
new = Config({'project': 'project', 'release': 'release', 'version': 'version'})
|
|
|
|
assert diff(old, new) == frozenset()
|
|
|
|
|
|
|
|
old = Config({'project': 'old', 'release': 'release'})
|
|
|
|
new = Config({'project': 'new', 'version': 'version'})
|
|
|
|
assert diff(old, new) == frozenset({'project', 'release', 'version'})
|