Fix #6531: Failed to load last environment object when extension added

This commit is contained in:
Takeshi KOMIYA 2019-06-29 22:05:25 +09:00
parent 05949f8347
commit d615eff08e
3 changed files with 26 additions and 5 deletions

View File

@ -48,6 +48,7 @@ Bugs fixed
* #6507: autosummary: crashes without no autosummary_generate setting * #6507: autosummary: crashes without no autosummary_generate setting
* #6511: LaTeX: autonumbered list can not be customized in LaTeX * #6511: LaTeX: autonumbered list can not be customized in LaTeX
since Sphinx 1.8.0 (refs: #6533) since Sphinx 1.8.0 (refs: #6533)
* #6531: Failed to load last environment object when extension added
Testing Testing
-------- --------

View File

@ -237,6 +237,8 @@ class BuildEnvironment:
self.config_status = CONFIG_OK self.config_status = CONFIG_OK
if self.config is None: if self.config is None:
self.config_status = CONFIG_NEW self.config_status = CONFIG_NEW
elif self.config.extensions != config.extensions:
self.config_status = CONFIG_EXTENSIONS_CHANGED
else: else:
# check if a config value was changed that affects how # check if a config value was changed that affects how
# doctrees are read # doctrees are read
@ -245,11 +247,6 @@ class BuildEnvironment:
self.config_status = CONFIG_CHANGED self.config_status = CONFIG_CHANGED
break break
# this value is not covered by the above loop because it is handled
# specially by the config class
if self.config.extensions != config.extensions:
self.config_status = CONFIG_EXTENSIONS_CHANGED
self.config = config self.config = config
def _update_settings(self, config): def _update_settings(self, config):

View File

@ -11,9 +11,32 @@ import pytest
from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.builders.latex import LaTeXBuilder from sphinx.builders.latex import LaTeXBuilder
from sphinx.environment import CONFIG_OK, CONFIG_CHANGED, CONFIG_EXTENSIONS_CHANGED, CONFIG_NEW
from sphinx.testing.comparer import PathComparer from sphinx.testing.comparer import PathComparer
@pytest.mark.sphinx('dummy', testroot='basic')
def test_config_status(make_app, app_params):
args, kwargs = app_params
# clean build
app1 = make_app(*args, freshenv=True, **kwargs)
assert app1.env.config_status == CONFIG_NEW
app1.build()
# incremental build (no config changed)
app2 = make_app(*args, **kwargs)
assert app2.env.config_status == CONFIG_OK
# incremental build (config entry changed)
app3 = make_app(*args, confoverrides={'master_doc': 'content'}, **kwargs)
assert app3.env.config_status == CONFIG_CHANGED
# incremental build (extension changed)
app4 = make_app(*args, confoverrides={'extensions': ['sphinx.ext.autodoc']}, **kwargs)
assert app4.env.config_status == CONFIG_EXTENSIONS_CHANGED
@pytest.mark.sphinx('dummy') @pytest.mark.sphinx('dummy')
def test_images(app): def test_images(app):
app.build() app.build()