Ejemplo n.º 1
0
 def test_getSphinxVersion2(self, mock_gca):
     """Check that _getSphinxVersion raises an exception if the Sphinx
     version info isn't present."""
     mock_gca.return_value = ("stderr",
                              "stdout - no version info here, sorry!")
     with self.assertRaises(ValueError):
         _getSphinxVersion('anything_since_replaced_by_mock')
Ejemplo n.º 2
0
 def test_getSphinxVersion2(self, mock_gca):
     """Check that _getSphinxVersion raises an exception if the Sphinx
     version info isn't present."""
     mock_gca.return_value = ("stderr",
                              "stdout - no version info here, sorry!")
     with self.assertRaises(ValueError):
         _getSphinxVersion('anything_since_replaced_by_mock')
Ejemplo n.º 3
0
    def test_getSphinxVersion5(self, mock_gca):
        """Check that _getSphinxVersion complies to sphinx version 1.3.1"""
        mock_gca.return_value = ("stdout", \
"""Sphinx (sphinx-build) 1.3.1
""")
        self.assertEqual(_getSphinxVersion('anything_since_replaced_by_mock'),
                         [1, 3, 1])
Ejemplo n.º 4
0
    def test_getSphinxVersion5(self, mock_gca):
        """Check that _getSphinxVersion complies to sphinx version 1.3.1"""
        mock_gca.return_value = ("stdout",
                                 """Sphinx (sphinx-build) 1.3.1
""")
        self.assertEqual(_getSphinxVersion('anything_since_replaced_by_mock'),
                         [1, 3, 1])
Ejemplo n.º 5
0
    def test_getSphinxVersion4(self, mock_gca):
        """Check that _getSphinxVersion complies to sphinx version 1.2.3"""
        mock_gca.return_value = ("stderr",
                                 """Sphinx (sphinx-build) 1.2.3
""")
        self.assertEqual(_getSphinxVersion('anything_since_replaced_by_mock'),
                         [1, 2, 3])
Ejemplo n.º 6
0
    def test_getSphinxVersion3(self, mock_gca):
        """Check that _getSphinxVersion complies to sphinx version 1.1.3"""
        mock_gca.return_value = ("stderr", """Sphinx v1.1.3
Usage: C:\Python27\Scripts\sphinx-build [options] sourcedir outdir [filenames...
]
""")
        self.assertEqual(_getSphinxVersion('anything_since_replaced_by_mock'),
                         [1, 1, 3])
Ejemplo n.º 7
0
    def test_getSphinxVersion3(self, mock_gca):
        """Check that _getSphinxVersion complies to sphinx version 1.1.3"""
        mock_gca.return_value = ("stderr",
                                 """Sphinx v1.1.3
Usage: C:\Python27\Scripts\sphinx-build [options] sourcedir outdir [filenames...
]
""")
        self.assertEqual(_getSphinxVersion('anything_since_replaced_by_mock'),
                         [1, 1, 3])
Ejemplo n.º 8
0
 def test_getSphinxVersion1(self):
     """Check that _getSphinxVersion raises an exception if the binary isn't
     present."""
     with self.assertRaises(OSError):
         _getSphinxVersion('this_executable_does_not_exist')
Ejemplo n.º 9
0
# Local application imports
# -------------------------
from enki.core.core import core
from enki.core.uisettings import UISettings
# Both of the two following lines are needed: the first, so we can later
# ``reload(enki.plugins.preview)``; the last, to instiantate ``SettingsWidget``.
import enki.plugins.preview
from enki.plugins.preview import CodeChatSettingsWidget, SphinxSettingsWidget
from import_fail import ImportFail
from enki.plugins.preview import _getSphinxVersion


_SPHINX_VERSION = [1, 3, 0]
try:
    sphinxVersion = _getSphinxVersion('sphinx-build')
except:
    sphinxIsAvailable = False
    sphinxVersion = None
else:
    sphinxIsAvailable = sphinxVersion >= _SPHINX_VERSION


def requiresSphinx():
    """ A decorator: a test requires Sphinx """
    if sphinxIsAvailable:
        return lambda func: func
    elif sphinxVersion is not None:
        return unittest.skip('Sphinx is too old. {} required'.format(_SPHINX_VERSION))
    else:
        return unittest.skip('Sphinx not found')
Ejemplo n.º 10
0
 def test_getSphinxVersion1(self):
     """Check that _getSphinxVersion raises an exception if the binary isn't
     present."""
     with self.assertRaises(OSError):
         _getSphinxVersion('this_executable_does_not_exist')
Ejemplo n.º 11
0
from PyQt5.QtTest import QTest

# Local application imports
# -------------------------
from enki.core.core import core
from enki.core.uisettings import UISettings
# Both of the two following lines are needed: the first, so we can later
# ``reload(enki.plugins.preview)``; the last, to instiantate ``SettingsWidget``.
import enki.plugins.preview
from enki.plugins.preview import CodeChatSettingsWidget, SphinxSettingsWidget, _getSphinxVersion
from import_fail import ImportFail
from enki.plugins.preview.preview_sync import CallbackManager

_SPHINX_VERSION = [1, 3, 0]
try:
    sphinxVersion = _getSphinxVersion('sphinx-build')
except:
    sphinxIsAvailable = False
    sphinxVersion = None
else:
    sphinxIsAvailable = sphinxVersion >= _SPHINX_VERSION


def requiresSphinx():
    """ A decorator: a test requires Sphinx """
    if sphinxIsAvailable:
        return lambda func: func
    elif sphinxVersion is not None:
        return unittest.skip(
            'Sphinx is too old. {} required'.format(_SPHINX_VERSION))
    else: