Skip to content

Commit 28928dc

Browse files
committed
Add test for SPHINX_AUTOBUILD_DEBUG
1 parent d706368 commit 28928dc

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ Debugging
171171
=========
172172

173173
If the ``SPHINX_AUTOBUILD_DEBUG`` environment variable is present
174+
(regardless of its value)
174175
and a file change is detected,
175176
its path and the currently active ignore expressions are printed.
176177
This is to help setting up the ignore expressions correctly.

tests/test_ignore.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import os
2+
3+
import pytest
4+
15
from sphinx_autobuild.filter import IgnoreFilter
26

37

@@ -72,3 +76,19 @@ def test_multiple_both():
7276
assert ignored("foo/random.txt")
7377
assert ignored("foo/module.pyc")
7478
assert ignored("bar/__pycache__/file.pyc")
79+
80+
81+
@pytest.mark.parametrize("is_debug", [True, False])
82+
def test_debug(is_debug, capfd):
83+
if is_debug:
84+
# also "0" is considered to mean "print debug output":
85+
os.environ["SPHINX_AUTOBUILD_DEBUG"] = "0"
86+
else:
87+
del os.environ["SPHINX_AUTOBUILD_DEBUG"]
88+
ignore_handler = IgnoreFilter([], [])
89+
ignore_handler("dummyfile")
90+
captured = capfd.readouterr()
91+
if is_debug:
92+
assert "SPHINX_AUTOBUILD_DEBUG" in captured.out
93+
else:
94+
assert "SPHINX_AUTOBUILD_DEBUG" not in captured.out

0 commit comments

Comments
 (0)