forked from openlp/openlp
Modified the check_dependencies.py script to only require mock if we're using Python 3.2 and earlier.
This commit is contained in:
parent
316f33c058
commit
3994669c1b
@ -44,7 +44,7 @@ from distutils.version import LooseVersion
|
||||
try:
|
||||
import nose
|
||||
except ImportError:
|
||||
pass
|
||||
nose = None
|
||||
|
||||
IS_WIN = sys.platform.startswith('win')
|
||||
|
||||
@ -90,21 +90,34 @@ MODULES = [
|
||||
|
||||
|
||||
OPTIONAL_MODULES = [
|
||||
('MySQLdb', ' (MySQL support)'),
|
||||
('psycopg2', ' (PostgreSQL support)'),
|
||||
('nose', ' (testing framework)'),
|
||||
('mock', ' (testing module)'),
|
||||
('MySQLdb', '(MySQL support)', True),
|
||||
('psycopg2', '(PostgreSQL support)', True),
|
||||
('nose', '(testing framework)', True),
|
||||
('mock', '(testing module)', sys.version_info[1] < 3),
|
||||
]
|
||||
|
||||
w = sys.stdout.write
|
||||
|
||||
|
||||
def check_vers(version, required, text):
|
||||
"""
|
||||
Check the version of a dependency. Returns ``True`` if the version is greater than or equal, or False if less than.
|
||||
|
||||
``version``
|
||||
The actual version of the dependency
|
||||
|
||||
``required``
|
||||
The required version of the dependency
|
||||
|
||||
``text``
|
||||
The dependency's name
|
||||
"""
|
||||
space = (27 - len(required) - len(text)) * ' '
|
||||
if not isinstance(version, str):
|
||||
version = '.'.join(map(str, version))
|
||||
if not isinstance(required, str):
|
||||
required = '.'.join(map(str, required))
|
||||
w(' %s >= %s ... ' % (text, required))
|
||||
w(' %s >= %s ... ' % (text, required) + space)
|
||||
if LooseVersion(version) >= LooseVersion(required):
|
||||
w(version + os.linesep)
|
||||
return True
|
||||
@ -113,6 +126,29 @@ def check_vers(version, required, text):
|
||||
return False
|
||||
|
||||
|
||||
def check_module(mod, text='', indent=' '):
|
||||
"""
|
||||
Check that a module is installed.
|
||||
|
||||
``mod``
|
||||
The module to check for.
|
||||
|
||||
``text``
|
||||
The text to display.
|
||||
|
||||
``indent``
|
||||
How much to indent the text by.
|
||||
"""
|
||||
space = (31 - len(mod) - len(text)) * ' '
|
||||
w(indent + '%s %s... ' % (mod, text) + space)
|
||||
try:
|
||||
__import__(mod)
|
||||
w('OK')
|
||||
except ImportError:
|
||||
w('FAIL')
|
||||
w(os.linesep)
|
||||
|
||||
|
||||
def print_vers_fail(required, text):
|
||||
print(' %s >= %s ... FAIL' % (text, required))
|
||||
|
||||
@ -143,18 +179,10 @@ def verify_versions():
|
||||
print_vers_fail(VERS['enchant'], 'enchant')
|
||||
|
||||
|
||||
def check_module(mod, text='', indent=' '):
|
||||
space = (30 - len(mod) - len(text)) * ' '
|
||||
w(indent + '%s%s... ' % (mod, text) + space)
|
||||
try:
|
||||
__import__(mod)
|
||||
w('OK')
|
||||
except ImportError:
|
||||
w('FAIL')
|
||||
w(os.linesep)
|
||||
|
||||
|
||||
def verify_pyenchant():
|
||||
def print_enchant_backends_and_languages():
|
||||
"""
|
||||
Check if PyEnchant is installed.
|
||||
"""
|
||||
w('Enchant (spell checker)... ')
|
||||
try:
|
||||
import enchant
|
||||
@ -167,14 +195,15 @@ def verify_pyenchant():
|
||||
w('FAIL' + os.linesep)
|
||||
|
||||
|
||||
def verify_pyqt():
|
||||
def print_qt_image_formats():
|
||||
"""
|
||||
Print out the image formats that Qt4 supports.
|
||||
"""
|
||||
w('Qt4 image formats... ')
|
||||
try:
|
||||
from PyQt4 import QtGui
|
||||
read_f = ', '.join([str(format).lower()
|
||||
for format in QtGui.QImageReader.supportedImageFormats()])
|
||||
write_f = ', '.join([str(format).lower()
|
||||
for format in QtGui.QImageWriter.supportedImageFormats()])
|
||||
read_f = ', '.join([bytes(fmt).decode().lower() for fmt in QtGui.QImageReader.supportedImageFormats()])
|
||||
write_f = ', '.join([bytes(fmt).decode().lower() for fmt in QtGui.QImageWriter.supportedImageFormats()])
|
||||
w(os.linesep)
|
||||
print(' read: %s' % read_f)
|
||||
print(' write: %s' % write_f)
|
||||
@ -183,20 +212,25 @@ def verify_pyqt():
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
Run the dependency checker.
|
||||
"""
|
||||
print('Checking Python version...')
|
||||
verify_python()
|
||||
print('Checking for modules...')
|
||||
for m in MODULES:
|
||||
check_module(m)
|
||||
print('Checking for optional modules...')
|
||||
for m in OPTIONAL_MODULES:
|
||||
check_module(m[0], text=m[1])
|
||||
if m[2]:
|
||||
check_module(m[0], text=m[1])
|
||||
if IS_WIN:
|
||||
print('Checking for Windows specific modules...')
|
||||
for m in WIN32_MODULES:
|
||||
check_module(m)
|
||||
verify_versions()
|
||||
verify_pyqt()
|
||||
verify_pyenchant()
|
||||
print_qt_image_formats()
|
||||
print_enchant_backends_and_languages()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -420,7 +420,7 @@ class TestPluginManager(TestCase):
|
||||
# THEN: The isActive() method should have been called, and initialise() method should NOT have been called
|
||||
mocked_plugin.is_active.assert_called_with()
|
||||
self.assertEqual(0, mocked_plugin.new_service_created.call_count,
|
||||
'The new_service_created() method should not have been called.')
|
||||
'The new_service_created() method should not have been called.')
|
||||
|
||||
def new_service_created_with_active_plugin_test(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user