diff options
Diffstat (limited to 'tests/test_environment.py')
-rw-r--r-- | tests/test_environment.py | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/tests/test_environment.py b/tests/test_environment.py index 65c82691d..4133a28fd 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -15,44 +15,38 @@ from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.builders.latex import LaTeXBuilder app = env = None -warnings = [] def setup_module(): global app, env app = SphinxTestApp(srcdir='root-envtest') env = app.env - env.set_warnfunc(lambda *args, **kwargs: warnings.append(args)) def teardown_module(): app.cleanup() -def warning_emitted(file, text): - for warning in warnings: - if len(warning) == 2 and file in warning[1] and text in warning[0]: - return True - return False - - # Tests are run in the order they appear in the file, therefore we can # afford to not run update() in the setup but in its own test def test_first_update(): - updated = env.update(app.config, app.srcdir, app.doctreedir, app) + updated = env.update(app.config, app.srcdir, app.doctreedir) assert set(updated) == env.found_docs == set(env.all_docs) # test if exclude_patterns works ok assert 'subdir/excluded' not in env.found_docs def test_images(): - assert warning_emitted('images', 'image file not readable: foo.png') - assert warning_emitted('images', 'nonlocal image URI found: ' - 'http://www.python.org/logo.png') + assert ('image file not readable: foo.png' + in app._warning.getvalue()) + assert ('nonlocal image URI found: http://www.python.org/logo.png' + in app._warning.getvalue()) tree = env.get_doctree('images') htmlbuilder = StandaloneHTMLBuilder(app) + htmlbuilder.set_environment(app.env) + htmlbuilder.init() htmlbuilder.imgpath = 'dummy' htmlbuilder.post_process_images(tree) assert set(htmlbuilder.images.keys()) == \ @@ -62,6 +56,8 @@ def test_images(): set(['img.png', 'img1.png', 'simg.png', 'svgimg.svg', 'img.foo.png']) latexbuilder = LaTeXBuilder(app) + latexbuilder.set_environment(app.env) + latexbuilder.init() latexbuilder.post_process_images(tree) assert set(latexbuilder.images.keys()) == \ set(['subdir/img.png', 'subdir/simg.png', 'img.png', 'img.pdf', @@ -79,7 +75,7 @@ def test_second_update(): # the contents.txt toctree; otherwise section numbers would shift (root / 'autodoc.txt').unlink() (root / 'new.txt').write_text('New file\n========\n') - updated = env.update(app.config, app.srcdir, app.doctreedir, app) + updated = env.update(app.config, app.srcdir, app.doctreedir) # "includes" and "images" are in there because they contain references # to nonexisting downloadable or image files, which are given another # chance to exist @@ -95,7 +91,7 @@ def test_env_read_docs(): app.connect('env-before-read-docs', on_env_read_docs_1) - read_docnames = env.update(app.config, app.srcdir, app.doctreedir, app) + read_docnames = env.update(app.config, app.srcdir, app.doctreedir) assert len(read_docnames) > 2 and read_docnames == sorted(read_docnames) def on_env_read_docs_2(app, env, docnames): @@ -103,7 +99,7 @@ def test_env_read_docs(): app.connect('env-before-read-docs', on_env_read_docs_2) - read_docnames = env.update(app.config, app.srcdir, app.doctreedir, app) + read_docnames = env.update(app.config, app.srcdir, app.doctreedir) assert len(read_docnames) == 2 |