diff --git a/openlp/core/common/applocation.py b/openlp/core/common/applocation.py index 1fce25000..2bc4027b6 100644 --- a/openlp/core/common/applocation.py +++ b/openlp/core/common/applocation.py @@ -110,7 +110,7 @@ class AppLocation(object): :param extension: Defaults to *None*. The extension to search for. For example:: - u'.png' + '.png' """ path = AppLocation.get_data_path() if section: diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 590452f73..3b7b31ca1 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -68,8 +68,7 @@ class Settings(QtCore.QSettings): ``__obsolete_settings__`` Each entry is structured in the following way:: - (u'general/enable slide loop', u'advanced/slide limits', - [(SlideLimits.Wrap, True), (SlideLimits.End, False)]) + ('general/enable slide loop', 'advanced/slide limits', [(SlideLimits.Wrap, True), (SlideLimits.End, False)]) The first entry is the *old key*; it will be removed. diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 9561baff4..a7cba33a0 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -296,8 +296,7 @@ def create_separated_list(string_list): :param string_list: List of unicode strings """ - if LooseVersion(Qt.PYQT_VERSION_STR) >= LooseVersion('4.9') and \ - LooseVersion(Qt.qVersion()) >= LooseVersion('4.8'): + if LooseVersion(Qt.PYQT_VERSION_STR) >= LooseVersion('4.9') and LooseVersion(Qt.qVersion()) >= LooseVersion('4.8'): return QtCore.QLocale().createSeparatedList(string_list) if not string_list: return '' diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 1f459524c..8cd13088d 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -129,7 +129,7 @@ class Plugin(QtCore.QObject, RegistryProperties): class MyPlugin(Plugin): def __init__(self): - super(MyPlugin, self).__init__('MyPlugin', version=u'0.1') + super(MyPlugin, self).__init__('MyPlugin', version='0.1') :param name: Defaults to *None*. The name of the plugin. :param default_settings: A dict containing the plugin's settings. The value to each key is the default value diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 17ead5346..d05200f2f 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -63,8 +63,7 @@ class ScreenList(object): """ Initialise the screen list. - ``desktop`` - A ``QDesktopWidget`` object. + :param desktop: A QDesktopWidget object. """ screen_list = cls() screen_list.desktop = desktop @@ -136,7 +135,7 @@ class ScreenList(object): Returns a list with the screens. This should only be used to display available screens to the user:: - [u'Screen 1 (primary)', u'Screen 2'] + ['Screen 1 (primary)', 'Screen 2'] """ screen_list = [] for screen in self.screen_list: @@ -153,9 +152,9 @@ class ScreenList(object): :param screen: A dict with the screen properties:: { - u'primary': True, - u'number': 0, - u'size': PyQt4.QtCore.QRect(0, 0, 1024, 768) + 'primary': True, + 'number': 0, + 'size': PyQt4.QtCore.QRect(0, 0, 1024, 768) } """ log.info('Screen %d found with resolution %s' % (screen['number'], screen['size'])) diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index e971bbec4..3825312bd 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -30,7 +30,7 @@ The About dialog. """ -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from .aboutdialog import Ui_AboutDialog from openlp.core.lib import translate diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 212fee4cd..b8b3941cd 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -30,7 +30,7 @@ The GUI widgets of the exception dialog. """ -from PyQt4 import QtCore, QtGui +from PyQt4 import QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_button, create_button_box diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index b9b5f5997..531c4b49f 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -199,8 +199,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard, RegistryProperties): self.no_internet_label.setText(self.no_internet_text + self.cancelWizardText) elif page_id == FirstTimePage.Defaults: self.theme_combo_box.clear() - for iter in range(self.themes_list_widget.count()): - item = self.themes_list_widget.item(iter) + for index in range(self.themes_list_widget.count()): + item = self.themes_list_widget.item(index) if item.checkState() == QtCore.Qt.Checked: self.theme_combo_box.addItem(item.text()) if self.has_run_wizard: @@ -292,13 +292,9 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard, RegistryProperties): """ themes = self.config.get('themes', 'files') themes = themes.split(',') - for theme in themes: - filename = self.config.get('theme_%s' % theme, 'filename') + for index, theme in enumerate(themes): screenshot = self.config.get('theme_%s' % theme, 'screenshot') - for index in range(self.themes_list_widget.count()): - item = self.themes_list_widget.item(index) - if item.data(QtCore.Qt.UserRole) == filename: - break + item = self.themes_list_widget.item(index) item.setIcon(build_icon(os.path.join(gettempdir(), 'openlp', screenshot))) def _get_file_size(self, url): diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 3246d58c4..22ea7ecfc 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -29,8 +29,6 @@ """ The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer class. """ -import os - from openlp.core.common import RegistryProperties from openlp.core.ui.media import MediaState diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 5e94dbd0e..b343755a0 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -33,10 +33,8 @@ import logging import mimetypes from datetime import datetime -from PyQt4 import QtGui from PyQt4.phonon import Phonon -from openlp.core.common import Settings from openlp.core.lib import translate from openlp.core.ui.media import MediaState diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 489eefa78..41caaab52 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -242,7 +242,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog, RegistryProperties) Creates a html element. If ``text`` is given, the element's text will set and if a ``parent`` is given, the element is appended. - :param tag: The html tag, e. g. ``u'span'``. Defaults to ``None``. + :param tag: The html tag, e. g. ``'span'``. Defaults to ``None``. :param text: The text for the tag. Defaults to ``None``. :param parent: The parent element. Defaults to ``None``. :param classId: Value for the class attribute diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 1f54f984b..0478f0ed0 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -190,7 +190,7 @@ class ThemesTab(SettingsTab): :param theme_list: The list of available themes:: - [u'Bible Theme', u'Song Theme'] + ['Bible Theme', 'Song Theme'] """ # Reload as may have been triggered by the ThemeManager. self.global_theme = Settings().value(self.settings_section + '/global theme') diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 5815457b5..5996296b5 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -279,7 +279,7 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): :param filters: The file extension filters. It should contain the file description as well as the file extension. For example:: - u'OpenLP 2.0 Databases (*.sqlite)' + 'OpenLP 2.0 Databases (*.sqlite)' """ if filters: filters += ';;' diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index a5b5f356a..add663132 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -113,7 +113,7 @@ def get_application_version(): """ Returns the application version of the running instance of OpenLP:: - {u'full': u'1.9.4-bzr1249', u'version': u'1.9.4', u'build': u'bzr1249'} + {'full': '1.9.4-bzr1249', 'version': '1.9.4', 'build': 'bzr1249'} """ global APPLICATION_VERSION if APPLICATION_VERSION: diff --git a/openlp/plugins/alerts/forms/__init__.py b/openlp/plugins/alerts/forms/__init__.py index 55d44372e..fbe3c7170 100644 --- a/openlp/plugins/alerts/forms/__init__.py +++ b/openlp/plugins/alerts/forms/__init__.py @@ -32,7 +32,7 @@ other class holds all the functional code, like slots and loading and saving. The first class, commonly known as the **Dialog** class, is typically named ``Ui_Dialog``. It is a slightly modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be -converting most strings from "" to u'' and using OpenLP's ``translate()`` function for translating strings. +converting most strings from "" to '' and using OpenLP's ``translate()`` function for translating strings. The second class, commonly known as the **Form** class, is typically named ``Form``. This class is the one which is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index 974d6d7a5..d6c77a9a3 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -33,7 +33,7 @@ other class holds all the functional code, like slots and loading and saving. The first class, commonly known as the **Dialog** class, is typically named ``Ui_Dialog``. It is a slightly modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be -converting most strings from "" to u'' and using OpenLP's ``translate()`` function for translating strings. +converting most strings from "" to '' and using OpenLP's ``translate()`` function for translating strings. The second class, commonly known as the **Form** class, is typically named ``Form``. This class is the one which is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 50a0e2a63..d67319797 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -262,7 +262,7 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False): For example:: - [(u'John', 3, 16, 18), (u'John', 4, 1, 1)] + [('John', 3, 16, 18), ('John', 4, 1, 1)] **Reference string details:** @@ -311,7 +311,7 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False): ``(?P[0-9]+)`` The ``to_verse`` reference is equivalent to group 2. - The full reference is matched against get_reference_match(u'full'). This regular expression looks like this: + The full reference is matched against get_reference_match('full'). This regular expression looks like this: ``^\s*(?!\s)(?P[\d]*[^\d]+)(?Dialog``. It is a slightly modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be -converting most strings from "" to u'' and using OpenLP's ``translate()`` function for translating strings. +converting most strings from "" to '' and using OpenLP's ``translate()`` function for translating strings. The second class, commonly known as the **Form** class, is typically named ``Form``. This class is the one which is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned diff --git a/openlp/plugins/images/lib/db.py b/openlp/plugins/images/lib/db.py index 68ca3d11d..896f93b17 100644 --- a/openlp/plugins/images/lib/db.py +++ b/openlp/plugins/images/lib/db.py @@ -31,7 +31,7 @@ The :mod:`db` module provides the database and schema that is the backend for th """ from sqlalchemy import Column, ForeignKey, Table, types -from sqlalchemy.orm import mapper, relation, reconstructor +from sqlalchemy.orm import mapper from openlp.core.lib.db import BaseModel, init_db diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 87d8e3311..92426334a 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -314,7 +314,6 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): def get_list(self, type=MediaType.Audio): media = Settings().value(self.settings_section + '/media files') media.sort(key=lambda filename: get_locale_key(os.path.split(str(filename))[1])) - extension = [] if type == MediaType.Audio: extension = self.media_controller.audio_extensions_list else: diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 6c8d7fb8c..3060bcdb0 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -354,7 +354,7 @@ class PresentationController(object): class MyPresentationController(PresentationController): def __init__(self, plugin): PresentationController.__init( - self, plugin, u'My Presenter App') + self, plugin, 'My Presenter App') :param plugin: Defaults to *None*. The presentationplugin object :param name: Name of the application, to appear in the application diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index 3094a0eda..eb29c12bf 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -34,7 +34,7 @@ code, like slots and loading and saving. The first class, commonly known as the **Dialog** class, is typically named ``Ui_Dialog``. It is a slightly modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be -converting most strings from "" to u'' and using OpenLP's ``translate()`` +converting most strings from "" to '' and using OpenLP's ``translate()`` function for translating strings. The second class, commonly known as the **Form** class, is typically named diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 79a69a015..bc2532b0d 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -122,8 +122,6 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): text = text[:position + 4] match = VERSE_REGEX.match(text) if match: - # TODO: Not used, remove? - # verse_tag = match.group(1) try: verse_num = int(match.group(2)) + 1 except ValueError: diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 21569a034..2a05f06cd 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -231,11 +231,11 @@ class SongImportForm(OpenLPWizard, RegistryProperties): """ Opens a QFileDialog and writes the filenames to the given listbox. - :param title: The title of the dialog (unicode). + :param title: The title of the dialog (str). :param listbox: A listbox (QListWidget). - :param filters: The file extension filters. It should contain the file descriptions - as well as the file extensions. For example:: - u'SongBeamer Files (*.sng)' + :param filters: The file extension filters. It should contain the file descriptions as well as the file + extensions. For example:: + 'SongBeamer Files (*.sng)' """ if filters: filters += ';;' diff --git a/openlp/plugins/songs/forms/songselectform.py b/openlp/plugins/songs/forms/songselectform.py index d3ff5ab52..f9f658c5b 100755 --- a/openlp/plugins/songs/forms/songselectform.py +++ b/openlp/plugins/songs/forms/songselectform.py @@ -319,8 +319,6 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): def on_search_finished(self): """ Slot which is called when the search is completed. - - :param songs: """ self.application.process_events() self.search_progress_bar.setVisible(False) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index aa9fbc4c9..95868ffa7 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -434,7 +434,7 @@ def strip_rtf(text, default_encoding=None): # Current font is the font tag we last met. font = '' # Character encoding is defined inside fonttable. - # font_table could contain eg u'0': u'cp1252' + # font_table could contain eg '0': u'cp1252' font_table = {'': ''} # Stack of things to keep track of when entering/leaving groups. stack = [] diff --git a/openlp/plugins/songs/lib/easyslidesimport.py b/openlp/plugins/songs/lib/easyslidesimport.py index e28e7bf97..ca9a9b755 100644 --- a/openlp/plugins/songs/lib/easyslidesimport.py +++ b/openlp/plugins/songs/lib/easyslidesimport.py @@ -292,7 +292,7 @@ class EasySlidesImport(SongImport): return True def _extract_region(self, line): - # this was true already: line[0:7] == u'[region': + # this was true already: line[0:7] == '[region': """ Extract the region from text diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 32730ce3c..288711b06 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -518,16 +518,8 @@ class SongMediaItem(MediaManagerItem): log.debug('service_load') if self.plugin.status != PluginStatus.Active or not item.data_string: return - if item.data_string['title'].find('@') == -1: - # FIXME: This file seems to be an old one (prior to 1.9.5), which means, that the search title - # (data_string[u'title']) is probably wrong. We add "@" to search title and hope that we do not add any - # duplicate. This should work for songs without alternate title. - temp = (re.compile(r'\W+', re.UNICODE).sub(' ', item.data_string['title'].strip()) + '@').strip().lower() - search_results = \ - self.plugin.manager.get_all_objects(Song, Song.search_title == temp, Song.search_title.asc()) - else: - search_results = self.plugin.manager.get_all_objects( - Song, Song.search_title == item.data_string['title'], Song.search_title.asc()) + search_results = self.plugin.manager.get_all_objects( + Song, Song.search_title == item.data_string['title'], Song.search_title.asc()) edit_id = 0 add_song = True if search_results: diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index a0b166ded..9c5e74c06 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -171,7 +171,7 @@ class SongBeamerImport(SongImport): :param line: The line in the file. It should consist of a tag and a value for this tag (unicode):: - u'#Title=Nearer my God to Thee' + '#Title=Nearer my God to Thee' """ tag_val = line.split('=', 1) if len(tag_val) == 1: diff --git a/openlp/plugins/songs/lib/songselect.py b/openlp/plugins/songs/lib/songselect.py index a18b08c8a..232cdb9cf 100644 --- a/openlp/plugins/songs/lib/songselect.py +++ b/openlp/plugins/songs/lib/songselect.py @@ -146,14 +146,14 @@ class SongSelectImport(object): try: song_page = BeautifulSoup(self.opener.open(song['link']).read(), 'lxml') except (TypeError, HTTPError) as e: - log.exception(u'Could not get song from SongSelect, %s', e) + log.exception('Could not get song from SongSelect, %s', e) return None if callback: callback() try: lyrics_page = BeautifulSoup(self.opener.open(song['link'] + '/lyrics').read(), 'lxml') except (TypeError, HTTPError): - log.exception(u'Could not get lyrics from SongSelect') + log.exception('Could not get lyrics from SongSelect') return None if callback: callback() diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 68641a1d5..b856cb53f 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -344,7 +344,7 @@ class OpenLyrics(object): """ Tests the given text for not closed formatting tags and returns a tuple consisting of two unicode strings:: - (u'{st}{r}', u'{/r}{/st}') + ('{st}{r}', '{/r}{/st}') The first unicode string are the start tags (for the next slide). The second unicode string are the end tags. diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index b4334a728..2e06e47fe 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -305,7 +305,7 @@ class TestLib(TestCase): # WHEN: We convert an image to a byte array result = image_to_byte(mocked_image) - # THEN: We should receive a value of u'base64mock' + # THEN: We should receive a value of 'base64mock' MockedQtCore.QByteArray.assert_called_with() MockedQtCore.QBuffer.assert_called_with(mocked_byte_array) mocked_buffer.open.assert_called_with('writeonly') diff --git a/tests/functional/openlp_core_utils/test_utils.py b/tests/functional/openlp_core_utils/test_utils.py index a97d757ea..075ecb14f 100644 --- a/tests/functional/openlp_core_utils/test_utils.py +++ b/tests/functional/openlp_core_utils/test_utils.py @@ -250,7 +250,7 @@ class TestUtils(TestCase): # THEN: The user agent is a Linux (or ChromeOS) user agent result = 'Linux' in user_agent or 'CrOS' in user_agent - self.assertTrue(result, u'The user agent should be a valid Linux user agent') + self.assertTrue(result, 'The user agent should be a valid Linux user agent') def get_user_agent_windows_test(self): """ @@ -265,7 +265,7 @@ class TestUtils(TestCase): user_agent = _get_user_agent() # THEN: The user agent is a Linux (or ChromeOS) user agent - self.assertIn('Windows', user_agent, u'The user agent should be a valid Windows user agent') + self.assertIn('Windows', user_agent, 'The user agent should be a valid Windows user agent') def get_user_agent_macos_test(self): """ @@ -280,7 +280,7 @@ class TestUtils(TestCase): user_agent = _get_user_agent() # THEN: The user agent is a Linux (or ChromeOS) user agent - self.assertIn('Mac OS X', user_agent, u'The user agent should be a valid OS X user agent') + self.assertIn('Mac OS X', user_agent, 'The user agent should be a valid OS X user agent') def get_user_agent_default_test(self): """ @@ -295,7 +295,7 @@ class TestUtils(TestCase): user_agent = _get_user_agent() # THEN: The user agent is a Linux (or ChromeOS) user agent - self.assertIn('NetBSD', user_agent, u'The user agent should be the default user agent') + self.assertIn('NetBSD', user_agent, 'The user agent should be the default user agent') def get_web_page_no_url_test(self): """ diff --git a/tests/interfaces/openlp_core_common/__init__.py b/tests/interfaces/openlp_core_common/__init__.py new file mode 100644 index 000000000..6b241e7fc --- /dev/null +++ b/tests/interfaces/openlp_core_common/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### diff --git a/tests/interfaces/openlp_core_ui/test_splashscreen.py b/tests/interfaces/openlp_core_common/test_historycombobox.py similarity index 74% rename from tests/interfaces/openlp_core_ui/test_splashscreen.py rename to tests/interfaces/openlp_core_common/test_historycombobox.py index 35c15f9ec..00a63f15f 100644 --- a/tests/interfaces/openlp_core_ui/test_splashscreen.py +++ b/tests/interfaces/openlp_core_common/test_historycombobox.py @@ -27,34 +27,39 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -Test the openlp.core.ui.splashscreen class. +Module to test the :mod:`~openlp.core.common.historycombobox` module. """ + from unittest import TestCase -from PyQt4 import QtGui +from PyQt4 import QtCore, QtGui, QtTest -from openlp.core.ui import SplashScreen +from openlp.core.common import Registry +from openlp.core.common import HistoryComboBox from tests.helpers.testmixin import TestMixin +from tests.interfaces import MagicMock, patch -class TestSplashScreen(TestCase, TestMixin): +class TestHistoryComboBox(TestCase, TestMixin): def setUp(self): + Registry.create() self.get_application() self.main_window = QtGui.QMainWindow() + Registry().register('main_window', self.main_window) + self.combo = HistoryComboBox(self.main_window) def tearDown(self): - """ - Delete all the C++ objects at the end so that we don't have a segfault - """ - del self.app - del self.main_window + del self.combo - def setupUi_test(self): + def getItems_test(self): """ - Test if the setupUi method.... + Test the getItems() method """ - # GIVEN: A splash screen instance. - splash = SplashScreen() + # GIVEN: The combo. - # THEN: Check if the splash has a setupUi method. - assert hasattr(splash, 'setupUi'), 'The Splash Screen should have a setupUi() method.' + # WHEN: Add two items. + self.combo.addItem('test1') + self.combo.addItem('test2') + + # THEN: The list of items should contain both strings. + self.assertEqual(self.combo.getItems(), ['test1', 'test2']) \ No newline at end of file diff --git a/tests/interfaces/openlp_core_lib/test_searchedit.py b/tests/interfaces/openlp_core_lib/test_searchedit.py index 22bf6fae3..f2cf18988 100644 --- a/tests/interfaces/openlp_core_lib/test_searchedit.py +++ b/tests/interfaces/openlp_core_lib/test_searchedit.py @@ -30,7 +30,6 @@ Module to test the EditCustomForm. """ from unittest import TestCase -from unittest.mock import MagicMock from PyQt4 import QtCore, QtGui, QtTest @@ -127,9 +126,3 @@ class TestSearchEdit(TestCase, TestMixin): # THEN: The search edit text should be cleared and the button be hidden. assert not self.search_edit.text(), "The search edit should not have any text." assert self.search_edit.clear_button.isHidden(), "The clear button should be hidden." - - def resize_event_test(self): - """ - Just check if the resizeEvent() method is re-implemented. - """ - assert hasattr(self.search_edit, "resizeEvent"), "The search edit should re-implement the resizeEvent method." diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index 905f167e9..7d14c7d9c 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -89,7 +89,7 @@ class TestStartFileRenameForm(TestCase, TestMixin): Test that the file_name_edit setFocus has called with True when executed """ # GIVEN: A mocked QDialog.exec_() method and mocked file_name_edit.setFocus() method. - with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: + with patch('PyQt4.QtGui.QDialog.exec_'): mocked_set_focus = MagicMock() self.form.file_name_edit.setFocus = mocked_set_focus