Various Cleanups

removed not working tests
- removed not needed imports
- removed u' from doc
- use enumerate() instead of second for loop
- do not override build-ins

bzr-revno: 2375
This commit is contained in:
Andreas Preikschat 2014-05-03 06:27:31 +01:00 committed by Tim Bentley
commit fe52d50619
43 changed files with 124 additions and 136 deletions

View File

@ -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:

View File

@ -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.

View File

@ -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 ''

View File

@ -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

View File

@ -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']))

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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 += ';;'

View File

@ -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:

View File

@ -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_<name>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 ``<name>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

View File

@ -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_<name>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 ``<name>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

View File

@ -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<to_verse>[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<book>[\d]*[^\d]+)(?<!\s)\s*``
The ``book`` group starts with the first non-whitespace character. There are optional leading digits followed by

View File

@ -405,7 +405,7 @@ class BiblesTab(SettingsTab):
:param theme_list:
The list of available themes::
[u'Bible Theme', u'Song Theme']
['Bible Theme', 'Song Theme']
"""
self.bible_theme_combo_box.clear()
self.bible_theme_combo_box.addItem('')

View File

@ -370,17 +370,16 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
This is probably the most used function. It retrieves the list of
verses based on the user's query.
:param reference_list: This is the list of references the media manager item wants. It is
a list of tuples, with the following format::
:param reference_list: This is the list of references the media manager item wants. It is a list of tuples, with
the following format::
(book_reference_id, chapter, start_verse, end_verse)
Therefore, when you are looking for multiple items, simply break
them up into references like this, bundle them into a list. This
function then runs through the list, and returns an amalgamated
list of ``Verse`` objects. For example::
Therefore, when you are looking for multiple items, simply break them up into references like this, bundle
them into a list. This function then runs through the list, and returns an amalgamated list of ``Verse``
objects. For example::
[(u'35', 1, 1, 1), (u'35', 2, 2, 3)]
[('35', 1, 1, 1), ('35', 2, 2, 3)]
:param show_error:
"""
log.debug('BibleDB.get_verses("%s")' % reference_list)

View File

@ -534,7 +534,7 @@ class HTTPBible(BibleDB, RegistryProperties):
them into a list. This function then runs through the list, and returns an amalgamated list of ``Verse``
objects. For example::
[(u'35', 1, 1, 1), (u'35', 2, 2, 3)]
[('35', 1, 1, 1), ('35', 2, 2, 3)]
"""
log.debug('HTTPBible.get_verses("%s")', reference_list)
for reference in reference_list:

View File

@ -54,19 +54,19 @@ class BibleFormat(object):
WebDownload = 3
@staticmethod
def get_class(format):
def get_class(bible_format):
"""
Return the appropriate implementation class.
:param format: The Bible format.
:param bible_format: The Bible format.
"""
if format == BibleFormat.OSIS:
if bible_format == BibleFormat.OSIS:
return OSISBible
elif format == BibleFormat.CSV:
elif bible_format == BibleFormat.CSV:
return CSVBible
elif format == BibleFormat.OpenSong:
elif bible_format == BibleFormat.OpenSong:
return OpenSongBible
elif format == BibleFormat.WebDownload:
elif bible_format == BibleFormat.WebDownload:
return HTTPBible
else:
return None

View File

@ -360,8 +360,7 @@ class BibleMediaItem(MediaManagerItem):
combo boxes on the 'Advanced Search' Tab. This is not of any importance of the 'Quick Search' Tab.
:param bible: The bible to initialise (unicode).
:param last_book_id: The "book reference id" of the book which is chosen at the moment.
(int)
:param last_book_id: The "book reference id" of the book which is chosen at the moment. (int)
"""
log.debug('initialise_advanced_bible %s, %s', bible, last_book_id)
book_data = self.plugin.manager.get_books(bible)
@ -421,9 +420,8 @@ class BibleMediaItem(MediaManagerItem):
def update_auto_completer(self):
"""
This updates the bible book completion list for the search field. The
completion depends on the bible. It is only updated when we are doing a
reference search, otherwise the auto completion list is removed.
This updates the bible book completion list for the search field. The completion depends on the bible. It is
only updated when we are doing a reference search, otherwise the auto completion list is removed.
"""
log.debug('update_auto_completer')
# Save the current search type to the configuration.
@ -593,8 +591,7 @@ class BibleMediaItem(MediaManagerItem):
:param range_from: The first number of the range (int).
:param range_to: The last number of the range (int).
:param combo: The combo box itself (QComboBox).
:param restore: If True, then the combo's currentText will be restored after
adjusting (if possible).
:param restore: If True, then the combo's currentText will be restored after adjusting (if possible).
"""
log.debug('adjust_combo_box %s, %s, %s', combo, range_from, range_to)
if restore:
@ -640,8 +637,8 @@ class BibleMediaItem(MediaManagerItem):
def on_quick_search_button(self):
"""
Does a quick search and saves the search results. Quick search can
either be "Reference Search" or "Text Search".
Does a quick search and saves the search results. Quick search can either be "Reference Search" or
"Text Search".
"""
log.debug('Quick Search Button clicked')
self.quickSearchButton.setEnabled(False)
@ -696,8 +693,7 @@ class BibleMediaItem(MediaManagerItem):
def display_results(self, bible, second_bible=''):
"""
Displays the search results in the media manager. All data needed for
further action is saved for/in each row.
Displays the search results in the media manager. All data needed for further action is saved for/in each row.
"""
items = self.build_display_results(bible, second_bible, self.search_results)
for bible_verse in items:
@ -708,8 +704,7 @@ class BibleMediaItem(MediaManagerItem):
def build_display_results(self, bible, second_bible, search_results):
"""
Displays the search results in the media manager. All data needed for
further action is saved for/in each row.
Displays the search results in the media manager. All data needed for further action is saved for/in each row.
"""
verse_separator = get_reference_separator('sep_v_display')
version = self.plugin.manager.get_meta_data(bible, 'name').value
@ -837,7 +832,6 @@ class BibleMediaItem(MediaManagerItem):
# If there are no more items we check whether we have to add bible_text.
if bible_text:
raw_slides.append(bible_text.lstrip())
bible_text = ''
# Service Item: Capabilities
if self.settings.layout_style == LayoutStyle.Continuous and not second_bible:
# Split the line but do not replace line breaks in renderer.
@ -859,9 +853,8 @@ class BibleMediaItem(MediaManagerItem):
def format_title(self, start_bitem, old_bitem):
"""
This method is called, when we have to change the title, because
we are at the end of a verse range. E. g. if we want to add
Genesis 1:1-6 as well as Daniel 2:14.
This method is called, when we have to change the title, because we are at the end of a verse range. E. g. if we
want to add Genesis 1:1-6 as well as Daniel 2:14.
:param start_bitem: The first item of a range.
:param old_bitem: The last item of a range.
@ -891,10 +884,8 @@ class BibleMediaItem(MediaManagerItem):
def check_title(self, bitem, old_bitem):
"""
This method checks if we are at the end of an verse range. If that is
the case, we return True, otherwise False. E. g. if we added
Genesis 1:1-6, but the next verse is Daniel 2:14, we return True.
This method checks if we are at the end of an verse range. If that is the case, we return True, otherwise False.
E. g. if we added Genesis 1:1-6, but the next verse is Daniel 2:14, we return True.
:param bitem: The item we are dealing with at the moment.
:param old_bitem: The item we were previously dealing with.
@ -918,20 +909,17 @@ class BibleMediaItem(MediaManagerItem):
return True
elif old_chapter + 1 == chapter and (verse != 1 or old_verse !=
self.plugin.manager.get_verse_count(old_bible, old_book, old_chapter)):
# We are in the following chapter, but the last verse was not the
# last verse of the chapter or the current verse is not the
# first one of the chapter.
# We are in the following chapter, but the last verse was not the last verse of the chapter or the current
# verse is not the first one of the chapter.
return True
return False
def format_verse(self, old_chapter, chapter, verse):
"""
Formats and returns the text, each verse starts with, for the given
chapter and verse. The text is either surrounded by round, square,
Formats and returns the text, each verse starts with, for the given chapter and verse. The text is either
surrounded by round, square, curly brackets or no brackets at all. For example::
curly brackets or no brackets at all. For example::
u'{su}1:1{/su}'
'{su}1:1{/su}'
:param old_chapter: The previous verse's chapter number (int).
:param chapter: The chapter number (int).

View File

@ -197,7 +197,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
self.slide_list_view.clear()
self.slide_list_view.addItems(slides)
else:
old_slides = []
old_row = self.slide_list_view.currentRow()
# Create a list with all (old/unedited) slides.
old_slides = [self.slide_list_view.item(row).text() for row in range(self.slide_list_view.count())]

View File

@ -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_<name>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 ``<name>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

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -34,7 +34,7 @@ code, like slots and loading and saving.
The first class, commonly known as the **Dialog** class, is typically named
``Ui_<name>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

View File

@ -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:

View File

@ -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 += ';;'

View File

@ -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)

View File

@ -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 = []

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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()

View File

@ -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.

View File

@ -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')

View File

@ -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):
"""

View File

@ -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 #
###############################################################################

View File

@ -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'])

View File

@ -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."

View File

@ -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