summaryrefslogtreecommitdiffstats
path: root/tests/test_builder.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 11:31:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 11:31:33 +0000
commite863fd965dd6253243c3342bd6f0adc4fc8aec4d (patch)
treea4c1b6491a82593950043c3f8b2530e80664d768 /tests/test_builder.py
parentInitial commit. (diff)
downloadsphinx-e863fd965dd6253243c3342bd6f0adc4fc8aec4d.tar.xz
sphinx-e863fd965dd6253243c3342bd6f0adc4fc8aec4d.zip
Adding upstream version 5.3.0.upstream/5.3.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_builder.py')
-rw-r--r--tests/test_builder.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_builder.py b/tests/test_builder.py
new file mode 100644
index 0000000..1ff8aea
--- /dev/null
+++ b/tests/test_builder.py
@@ -0,0 +1,39 @@
+"""Test the Builder class."""
+import pytest
+
+
+@pytest.mark.sphinx('dummy', srcdir="test_builder", freshenv=True)
+def test_incremental_reading(app):
+ # first reading
+ updated = app.builder.read()
+ assert set(updated) == app.env.found_docs == set(app.env.all_docs)
+ assert updated == sorted(updated) # sorted by alphanumeric
+
+ # 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', encoding='utf8')
+ app.env.all_docs['index'] = 0 # mark as modified
+ (app.srcdir / 'autodoc.txt').unlink()
+
+ # second reading
+ updated = app.builder.read()
+
+ assert set(updated) == {'index', 'new'}
+ assert 'autodoc' not in app.env.all_docs
+ assert 'autodoc' not in app.env.found_docs
+
+
+@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)
+
+ # second reading
+ updated = app.builder.read()
+
+ # "index" is listed up to updated because it contains references
+ # to nonexisting downloadable or image files
+ assert set(updated) == {'index'}