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:
|
try:
|
||||||
import nose
|
import nose
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
nose = None
|
||||||
|
|
||||||
IS_WIN = sys.platform.startswith('win')
|
IS_WIN = sys.platform.startswith('win')
|
||||||
|
|
||||||
@ -90,21 +90,34 @@ MODULES = [
|
|||||||
|
|
||||||
|
|
||||||
OPTIONAL_MODULES = [
|
OPTIONAL_MODULES = [
|
||||||
('MySQLdb', ' (MySQL support)'),
|
('MySQLdb', '(MySQL support)', True),
|
||||||
('psycopg2', ' (PostgreSQL support)'),
|
('psycopg2', '(PostgreSQL support)', True),
|
||||||
('nose', ' (testing framework)'),
|
('nose', '(testing framework)', True),
|
||||||
('mock', ' (testing module)'),
|
('mock', '(testing module)', sys.version_info[1] < 3),
|
||||||
]
|
]
|
||||||
|
|
||||||
w = sys.stdout.write
|
w = sys.stdout.write
|
||||||
|
|
||||||
|
|
||||||
def check_vers(version, required, text):
|
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):
|
if not isinstance(version, str):
|
||||||
version = '.'.join(map(str, version))
|
version = '.'.join(map(str, version))
|
||||||
if not isinstance(required, str):
|
if not isinstance(required, str):
|
||||||
required = '.'.join(map(str, required))
|
required = '.'.join(map(str, required))
|
||||||
w(' %s >= %s ... ' % (text, required))
|
w(' %s >= %s ... ' % (text, required) + space)
|
||||||
if LooseVersion(version) >= LooseVersion(required):
|
if LooseVersion(version) >= LooseVersion(required):
|
||||||
w(version + os.linesep)
|
w(version + os.linesep)
|
||||||
return True
|
return True
|
||||||
@ -113,6 +126,29 @@ def check_vers(version, required, text):
|
|||||||
return False
|
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):
|
def print_vers_fail(required, text):
|
||||||
print(' %s >= %s ... FAIL' % (text, required))
|
print(' %s >= %s ... FAIL' % (text, required))
|
||||||
|
|
||||||
@ -143,18 +179,10 @@ def verify_versions():
|
|||||||
print_vers_fail(VERS['enchant'], 'enchant')
|
print_vers_fail(VERS['enchant'], 'enchant')
|
||||||
|
|
||||||
|
|
||||||
def check_module(mod, text='', indent=' '):
|
def print_enchant_backends_and_languages():
|
||||||
space = (30 - len(mod) - len(text)) * ' '
|
"""
|
||||||
w(indent + '%s%s... ' % (mod, text) + space)
|
Check if PyEnchant is installed.
|
||||||
try:
|
"""
|
||||||
__import__(mod)
|
|
||||||
w('OK')
|
|
||||||
except ImportError:
|
|
||||||
w('FAIL')
|
|
||||||
w(os.linesep)
|
|
||||||
|
|
||||||
|
|
||||||
def verify_pyenchant():
|
|
||||||
w('Enchant (spell checker)... ')
|
w('Enchant (spell checker)... ')
|
||||||
try:
|
try:
|
||||||
import enchant
|
import enchant
|
||||||
@ -167,14 +195,15 @@ def verify_pyenchant():
|
|||||||
w('FAIL' + os.linesep)
|
w('FAIL' + os.linesep)
|
||||||
|
|
||||||
|
|
||||||
def verify_pyqt():
|
def print_qt_image_formats():
|
||||||
|
"""
|
||||||
|
Print out the image formats that Qt4 supports.
|
||||||
|
"""
|
||||||
w('Qt4 image formats... ')
|
w('Qt4 image formats... ')
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
read_f = ', '.join([str(format).lower()
|
read_f = ', '.join([bytes(fmt).decode().lower() for fmt in QtGui.QImageReader.supportedImageFormats()])
|
||||||
for format in QtGui.QImageReader.supportedImageFormats()])
|
write_f = ', '.join([bytes(fmt).decode().lower() for fmt in QtGui.QImageWriter.supportedImageFormats()])
|
||||||
write_f = ', '.join([str(format).lower()
|
|
||||||
for format in QtGui.QImageWriter.supportedImageFormats()])
|
|
||||||
w(os.linesep)
|
w(os.linesep)
|
||||||
print(' read: %s' % read_f)
|
print(' read: %s' % read_f)
|
||||||
print(' write: %s' % write_f)
|
print(' write: %s' % write_f)
|
||||||
@ -183,20 +212,25 @@ def verify_pyqt():
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
"""
|
||||||
|
Run the dependency checker.
|
||||||
|
"""
|
||||||
|
print('Checking Python version...')
|
||||||
verify_python()
|
verify_python()
|
||||||
print('Checking for modules...')
|
print('Checking for modules...')
|
||||||
for m in MODULES:
|
for m in MODULES:
|
||||||
check_module(m)
|
check_module(m)
|
||||||
print('Checking for optional modules...')
|
print('Checking for optional modules...')
|
||||||
for m in 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:
|
if IS_WIN:
|
||||||
print('Checking for Windows specific modules...')
|
print('Checking for Windows specific modules...')
|
||||||
for m in WIN32_MODULES:
|
for m in WIN32_MODULES:
|
||||||
check_module(m)
|
check_module(m)
|
||||||
verify_versions()
|
verify_versions()
|
||||||
verify_pyqt()
|
print_qt_image_formats()
|
||||||
verify_pyenchant()
|
print_enchant_backends_and_languages()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
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
|
# THEN: The isActive() method should have been called, and initialise() method should NOT have been called
|
||||||
mocked_plugin.is_active.assert_called_with()
|
mocked_plugin.is_active.assert_called_with()
|
||||||
self.assertEqual(0, mocked_plugin.new_service_created.call_count,
|
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):
|
def new_service_created_with_active_plugin_test(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user