Files
sphinx/tests/test_builder.py
T

48 lines
1.4 KiB
Python
Raw Normal View History

2018-02-24 01:16:27 +09:00
"""
test_builder
~~~~~~~~
Test the Builder class.
2021-01-01 02:00:29 +09:00
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
2018-02-24 01:16:27 +09:00
:license: BSD, see LICENSE for details.
"""
import pytest
2019-02-03 22:10:43 +09:00
@pytest.mark.sphinx('dummy', srcdir="test_builder", freshenv=True)
2018-02-24 01:16:27 +09:00
def test_incremental_reading(app):
# first reading
updated = app.builder.read()
assert set(updated) == app.env.found_docs == set(app.env.all_docs)
2019-02-03 22:10:43 +09:00
assert updated == sorted(updated) # sorted by alphanumeric
2018-02-24 01:16:27 +09:00
# test if exclude_patterns works ok
assert 'subdir/excluded' not in app.env.found_docs
# before second reading, add, modify and remove source files
(app.srcdir / 'new.txt').write_text('New file\n========\n')
app.env.all_docs['index'] = 0 # mark as modified
2018-02-24 01:16:27 +09:00
(app.srcdir / 'autodoc.txt').unlink()
# second reading
updated = app.builder.read()
assert set(updated) == {'index', 'new'}
2018-02-24 01:16:27 +09:00
assert 'autodoc' not in app.env.all_docs
assert 'autodoc' not in app.env.found_docs
2019-02-03 22:10:43 +09:00
@pytest.mark.sphinx('dummy', testroot='warnings', freshenv=True)
def test_incremental_reading_for_missing_files(app):
# first reading
updated = app.builder.read()
assert set(updated) == app.env.found_docs == set(app.env.all_docs)
2018-02-24 01:16:27 +09:00
2019-02-03 22:10:43 +09:00
# second reading
updated = app.builder.read()
2018-02-24 01:16:27 +09:00
2019-02-03 22:10:43 +09:00
# "index" is listed up to updated because it contains references
# to nonexisting downloadable or image files
assert set(updated) == {'index'}