Fix #2235: `needs_sphinx` supports micro version comparison

This commit is contained in:
Takeshi KOMIYA 2016-01-21 13:51:17 +09:00
parent b0e02b4a12
commit 04a8c26eab
4 changed files with 30 additions and 2 deletions

View File

@ -45,6 +45,7 @@ Features added
* #656: Add ``graphviz_dot`` option to graphviz directives to switch the ``dot`` command
* #1939: Added the ``dummy`` builder: syntax check without output.
* #2230: Add ``math_number_all`` option to number all displayed math in math extensions
* #2235: ``needs_sphinx`` supports micro version comparison
Bugs fixed
----------

View File

@ -220,6 +220,9 @@ General configuration
.. versionadded:: 1.0
.. versionchanged:: 1.4
also accepts micro version string
.. confval:: needs_extensions
This value can be a dictionary specifying version requirements for extensions

View File

@ -162,7 +162,7 @@ class Sphinx(object):
# check the Sphinx version if requested
if self.config.needs_sphinx and \
self.config.needs_sphinx > sphinx.__display_version__[:3]:
self.config.needs_sphinx > sphinx.__display_version__:
raise VersionRequirementError(
'This project needs at least Sphinx v%s and therefore cannot '
'be built with this version.' % self.config.needs_sphinx)

View File

@ -10,10 +10,12 @@
:license: BSD, see LICENSE for details.
"""
from six import PY2, PY3, StringIO, iteritems
from mock import patch
from util import TestApp, with_app, gen_with_app, with_tempdir, \
raises, raises_msg, assert_in, assert_not_in
import sphinx
from sphinx.config import Config
from sphinx.errors import ExtensionError, ConfigError, VersionRequirementError
@ -120,9 +122,31 @@ def test_errors_if_setup_is_not_callable(dir):
raises_msg(ConfigError, 'callable', TestApp, srcdir=dir)
@patch.object(sphinx, '__display_version__', '1.3.4')
def test_needs_sphinx():
# micro version
app = TestApp(confoverrides={'needs_sphinx': '1.3.3'}) # OK: less
app.cleanup()
app = TestApp(confoverrides={'needs_sphinx': '1.3.4'}) # OK: equals
app.cleanup()
raises(VersionRequirementError, TestApp,
confoverrides={'needs_sphinx': '9.9'})
confoverrides={'needs_sphinx': '1.3.5'}) # NG: greater
# minor version
app = TestApp(confoverrides={'needs_sphinx': '1.2'}) # OK: less
app.cleanup()
app = TestApp(confoverrides={'needs_sphinx': '1.3'}) # OK: equals
app.cleanup()
raises(VersionRequirementError, TestApp,
confoverrides={'needs_sphinx': '1.4'}) # NG: greater
# major version
app = TestApp(confoverrides={'needs_sphinx': '0'}) # OK: less
app.cleanup()
app = TestApp(confoverrides={'needs_sphinx': '1'}) # OK: equals
app.cleanup()
raises(VersionRequirementError, TestApp,
confoverrides={'needs_sphinx': '2'}) # NG: greater
@with_tempdir