Add configuration option
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"""Integration tests for sphinx-llms-txt."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from sphinx.testing.util import _clean_up_global_state
|
||||
|
||||
|
||||
def test_build_html_with_llms_txt(basic_sphinx_app):
|
||||
@@ -68,3 +70,37 @@ def test_custom_filename(temp_dir, rootdir):
|
||||
# Safe unlink that works with older Python versions
|
||||
if hasattr(app, "docutils_conf_path") and app.docutils_conf_path.exists():
|
||||
app.docutils_conf_path.unlink()
|
||||
|
||||
|
||||
def test_max_lines_limit(temp_dir, rootdir):
|
||||
"""Test that the max lines limit works correctly."""
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
src_dir = rootdir / "basic"
|
||||
|
||||
# Create a new test app with a small line limit
|
||||
app = SphinxTestApp(
|
||||
srcdir=src_dir,
|
||||
builddir=temp_dir,
|
||||
buildername="html",
|
||||
freshenv=True,
|
||||
confoverrides={
|
||||
"llms_txt_filename": "limited.txt",
|
||||
"llms_txt_max_lines": 10, # Set a small limit to trigger the warning
|
||||
"llms_txt_verbose": True,
|
||||
},
|
||||
)
|
||||
|
||||
app.build()
|
||||
|
||||
# Check that the output file was NOT created (since it would exceed the limit)
|
||||
output_file = Path(app.outdir) / "limited.txt"
|
||||
assert not output_file.exists(), f"Output file {output_file} exists but should not when limit is exceeded"
|
||||
|
||||
# Custom cleanup to avoid missing_ok issue
|
||||
sys.path[:] = app._saved_path
|
||||
_clean_up_global_state()
|
||||
|
||||
# Safe unlink
|
||||
if hasattr(app, "docutils_conf_path") and app.docutils_conf_path.exists():
|
||||
app.docutils_conf_path.unlink()
|
||||
|
||||
Reference in New Issue
Block a user