-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tests] ToC: ordering condition involving title generation. #12120
Comments
I'm starting work on this bug myself, partly because I feel that this may be a good way to learn more about The fix doesn't appear to be as straightforward as I had sensed that it might be when I added the good-first-issue label; even so there could be benefits to figuring out the fix in a newcomer-friendly way. So far I've adjusted the @with_text_app()
def test_nonascii_title_line_tmp(app):
app.config.text_secnumber_suffix = ' '
app.build()
app.config.text_secnumber_suffix = '. '
app.build()
result = (app.outdir / 'nonascii_title.txt').read_text(encoding='utf8')
expect_underline = '*********'
result_underline = result.splitlines()[1].strip()
assert result_underline == expect_underline
|
Adding some comments to that: @with_text_app()
def test_nonascii_title_line_tmp(app):
# after removing these two lines, the test begins passing: why?
app.config.text_secnumber_suffix = ' '
app.build()
# the two lines below are the expected / correct test build configuration
app.config.text_secnumber_suffix = '. '
app.build()
result = (app.outdir / 'nonascii_title.txt').read_text(encoding='utf8')
expect_underline = '*********'
result_underline = result.splitlines()[1].strip()
assert result_underline == expect_underline |
Referring back to this bug's description: requesting that the @with_text_app(freshenv=True) # this avoids the test failure
def test_nonascii_title_line_tmp(app):
app.build() # an alternative avoidance is to rewrite this line to: app.build(force_all=True)
result = (app.outdir / 'nonascii_title.txt').read_text(encoding='utf8')
expect_underline = '*********'
result_underline = result.splitlines()[1].strip()
assert result_underline == expect_underline Either of the two presented modifications result in:
However, I would like to investigate further and determine whether we could adjust Sphinx to allow these build actions -- that appear valid when written in source code -- to function as expected, without needing to adjust the test. Edit: 20240907: adjust the retest command and output to more-accurately correspond to the repro case in the bug description. |
As illustrated in the adjusted minimal repro test case -- this problem occurs when a second In general, Sphinx is designed to detect modification to certain configuration settings, and should refresh the sphinx/sphinx/environment/__init__.py Lines 344 to 350 in 0438178
The sphinx/sphinx/builders/text.py Line 93 in 0438178
However, there seems to be some code that overrides the resulting sphinx/sphinx/builders/__init__.py Lines 480 to 481 in 0438178
Commenting out the |
The core of the problem appears to be that an in-process A question that raises is: should config modification be supported between two adjacent(*) in-process builds? If we do want to support in-process between-build config modification, then we could adjust the application code to attempt to detect those modifications. This could perhaps re-use the same invalidation detection methods as the file-based (pickle) env cache -- or instead it could use a monotonic timestamp. If we do not want to support in-process between-build config modification, then we could update the tests so that each of them are isolated (independent) of the other's configuration. (*) In-process config modification during a build itself would seem like a recipe for undefined and nondeterministic results, especially during parallelised builds. So that's out-of-scope -- this comment relates solely to modifications that occur after a build has already completed and before another build may begin. |
I think it would be much simpler not to support these. The benefit would seem to be fairly marginal for the majority of anticipated use-cases (single documentation projects built within a single self-contained process during each build) -- and there is hidden future complexity (for example: So it feels to me that we should isolate these two test cases, and offer that as a resolution for this bug. |
Describe the bug
When running text-builder tests from the suite from commit bf0bec3 using
pytest tests/test_builders/test_build_text.py
, thetest_nonascii_title_line
test case fails whentest_secnums
is evaluated beforetest_nonascii_title_line
.How to Reproduce
From a checkout of 23eb545 and using
pytest==8.1.1
:$ pytest -vv tests/test_builders/test_build_text.py tests/test_builders/test_build_text.py -k 'secnum or nonascii_title'
(
Environment Information
Sphinx extensions
Additional context
Relates to #11285.
The text was updated successfully, but these errors were encountered: