forked from openlp/openlp
Yield fixtures are deprecated; the regular fixture does the same job
This commit is contained in:
parent
5879ebd4d6
commit
3fb4eee9f3
@ -40,7 +40,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def qapp(qtbot):
|
||||
"""An instance of QApplication"""
|
||||
qt_api.QApplication.instance()
|
||||
@ -49,7 +49,7 @@ def qapp(qtbot):
|
||||
del app
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def mocked_qapp():
|
||||
"""A mocked instance of QApplication"""
|
||||
app = MagicMock()
|
||||
@ -57,14 +57,14 @@ def mocked_qapp():
|
||||
del app
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def registry():
|
||||
"""An instance of the Registry"""
|
||||
yield Registry.create()
|
||||
Registry._instances = {}
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def settings(qapp, registry):
|
||||
"""A Settings() instance"""
|
||||
fd, ini_file = mkstemp('.ini')
|
||||
@ -85,7 +85,7 @@ def settings(qapp, registry):
|
||||
os.unlink(Settings().fileName())
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def mock_settings(qapp, registry):
|
||||
"""A Mock Settings() instance"""
|
||||
# Create and register a mock settings object to work with
|
||||
@ -99,7 +99,7 @@ def mock_settings(qapp, registry):
|
||||
del mk_settings
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def state():
|
||||
yield State().load_settings()
|
||||
State._instances = {}
|
||||
@ -112,7 +112,7 @@ def state_media(state):
|
||||
State().flush_preconditions()
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def temp_folder():
|
||||
t_folder = mkdtemp(prefix='openlp_')
|
||||
yield t_folder
|
||||
|
@ -33,7 +33,7 @@ from openlp.core.common.registry import Registry
|
||||
ZERO_URL = '0.0.0.0'
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def api_tab(settings):
|
||||
Registry().set_flag('website_version', '00-00-0000')
|
||||
parent = QtWidgets.QMainWindow()
|
||||
|
@ -29,7 +29,7 @@ from openlp.core.api.websockets import WebSocketServer
|
||||
from openlp.core.common.registry import Registry
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def poller(settings):
|
||||
poll = Poller()
|
||||
yield poll
|
||||
|
@ -34,7 +34,7 @@ MOCK_ACTION1 = MagicMock(**{'text.return_value': 'first'})
|
||||
MOCK_ACTION2 = MagicMock(**{'text.return_value': 'second'})
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def action_list(settings):
|
||||
act_list = ActionList.get_instance()
|
||||
yield act_list
|
||||
|
@ -35,7 +35,7 @@ from openlp.core.lib.db import get_upgrade_op, init_db
|
||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def op():
|
||||
tmp_folder = mkdtemp()
|
||||
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
||||
|
@ -31,7 +31,7 @@ from openlp.core.common.httputils import ProxyMode, download_file, get_proxy_set
|
||||
get_random_user_agent, get_web_page
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def temp_file(settings):
|
||||
tmp_file = os.path.join(tempfile.gettempdir(), 'testfile')
|
||||
yield tmp_file
|
||||
|
@ -28,7 +28,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.core.lib.mediamanageritem import MediaManagerItem
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def media_env():
|
||||
setup_patcher = patch('openlp.core.lib.mediamanageritem.MediaManagerItem._setup')
|
||||
setup_patcher.start()
|
||||
|
@ -37,7 +37,7 @@ TEST_PATH = RESOURCE_PATH / 'media'
|
||||
TEST_MEDIA = [['avi_file.avi', 61495], ['mp3_file.mp3', 134426], ['mpg_file.mpg', 9404], ['mp4_file.mp4', 188336]]
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def media_env(registry):
|
||||
"""Local test setup"""
|
||||
Registry().register('service_manager', MagicMock())
|
||||
|
@ -35,7 +35,7 @@ from openlp.core.ui.media.vlcplayer import VlcPlayer, get_vlc
|
||||
from tests.helpers import MockDateTime
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def vlc_env():
|
||||
"""Local test setup"""
|
||||
if 'VLC_PLUGIN_PATH' in os.environ:
|
||||
|
@ -48,7 +48,7 @@ def ftf_app(registry, qapp):
|
||||
Registry().register('application', qapp)
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def download_env(registry):
|
||||
download_worker_patcher = patch('openlp.core.ui.firsttimeform.DownloadWorker')
|
||||
run_thread_patcher = patch('openlp.core.ui.firsttimeform.run_thread')
|
||||
|
@ -27,7 +27,7 @@ from unittest.mock import MagicMock, call, patch
|
||||
from openlp.core.ui.formattingtagform import FormattingTagForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def tagform_env(registry):
|
||||
setup_patcher = patch('openlp.core.ui.formattingtagform.FormattingTagForm._setup')
|
||||
mocked_setup_patcher = setup_patcher.start()
|
||||
|
@ -46,7 +46,7 @@ def _create_mock_action(parent, name, **kwargs):
|
||||
return action
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def main_window(state, settings, mocked_qapp):
|
||||
app = Registry().get('application')
|
||||
app.set_busy_cursor = MagicMock()
|
||||
|
@ -27,7 +27,7 @@ from unittest.mock import MagicMock, call, patch
|
||||
from openlp.core.widgets.buttons import ColorButton
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def buttons_env():
|
||||
change_color_patcher = patch('openlp.core.widgets.buttons.ColorButton.change_color')
|
||||
clicked_patcher = patch('openlp.core.widgets.buttons.ColorButton.clicked')
|
||||
|
@ -37,7 +37,7 @@ def clapperboard(mock_settings):
|
||||
return UiIcons().clapperboard
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def preview_widget_env():
|
||||
"""Local test setup"""
|
||||
parent_patcher = patch('openlp.core.widgets.views.ListPreviewWidget.parent')
|
||||
|
@ -55,14 +55,14 @@ def error_message_box(settings):
|
||||
m_box.stop()
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def mocked_open():
|
||||
m_open = patch.object(Path, 'open')
|
||||
yield m_open.start()
|
||||
m_open.stop()
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def mocked_setup():
|
||||
s_up = patch('openlp.plugins.bibles.lib.db.BibleDB._setup')
|
||||
yield s_up.start()
|
||||
|
@ -29,7 +29,7 @@ from openlp.plugins.bibles import lib
|
||||
from openlp.plugins.bibles.lib import SearchResults, get_reference_match, update_reference_separators
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def mocked_bible_test(registry):
|
||||
"""Local test setup"""
|
||||
ret_value = MagicMock(**{'value.return_value': ''})
|
||||
|
@ -62,7 +62,7 @@ def mocked_timer():
|
||||
return patch('openlp.plugins.bibles.lib.mediaitem.QtCore.QTimer').start()
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def mocked_log():
|
||||
return patch('openlp.plugins.bibles.lib.mediaitem.log').start()
|
||||
|
||||
|
@ -35,14 +35,14 @@ from tests.utils.constants import RESOURCE_PATH
|
||||
TEST_PATH = RESOURCE_PATH / 'bibles'
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def manager():
|
||||
db_man = patch('openlp.plugins.bibles.lib.db.Manager')
|
||||
yield db_man.start()
|
||||
db_man.stop()
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def mocked_find_and_create_book():
|
||||
facb = patch.object(BibleImport, 'find_and_create_book')
|
||||
yield facb.start()
|
||||
|
@ -35,7 +35,7 @@ from openlp.plugins.bibles.lib import upgrade
|
||||
from tests.utils.constants import RESOURCE_PATH
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def mock_message_box():
|
||||
patched_message_box = patch('openlp.plugins.bibles.lib.upgrade.QtWidgets.QMessageBox')
|
||||
mocked_message_box = patched_message_box.start()
|
||||
@ -51,7 +51,7 @@ def mock_message_box():
|
||||
patched_message_box.stop()
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def db_url():
|
||||
tmp_path = Path(mkdtemp())
|
||||
db_path = RESOURCE_PATH / 'bibles' / 'web-bible-2.4.6-proxy-meta-v1.sqlite'
|
||||
|
@ -35,14 +35,14 @@ from openlp.plugins.images.lib import upgrade
|
||||
from tests.utils.constants import RESOURCE_PATH
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def temp_path():
|
||||
tmp_path = Path(mkdtemp())
|
||||
yield tmp_path
|
||||
shutil.rmtree(tmp_path, ignore_errors=True)
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def db_url():
|
||||
tmp_path = Path(mkdtemp())
|
||||
db_path = RESOURCE_PATH / 'images' / 'image-v0.sqlite'
|
||||
|
@ -40,7 +40,7 @@ def media_item(settings):
|
||||
return m_item
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def mock_plugin(temp_folder):
|
||||
m_plugin = MagicMock()
|
||||
m_plugin.settings_section = temp_folder
|
||||
|
@ -35,7 +35,7 @@ from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDoc
|
||||
from tests.utils.constants import RESOURCE_PATH
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def pdf_env(settings, mock_plugin, mocked_qapp):
|
||||
temp_folder_path = Path(mkdtemp())
|
||||
thumbnail_folder_path = Path(mkdtemp())
|
||||
|
@ -32,7 +32,7 @@ from openlp.plugins.presentations.lib.presentationcontroller import Presentation
|
||||
FOLDER_TO_PATCH = 'openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument.get_thumbnail_folder'
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def get_thumbnail_folder(settings):
|
||||
gtf = patch('openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument.get_thumbnail_folder',
|
||||
return_value=Path())
|
||||
@ -40,14 +40,14 @@ def get_thumbnail_folder(settings):
|
||||
gtf.stop()
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def create_paths(settings):
|
||||
c_paths = patch('openlp.plugins.presentations.lib.presentationcontroller.create_paths')
|
||||
yield c_paths.start()
|
||||
c_paths.stop()
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def setup(settings):
|
||||
s_up = patch('openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument._setup')
|
||||
yield s_up.start()
|
||||
|
@ -88,7 +88,7 @@ ${title}<br/>
|
||||
}
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def media_item(settings):
|
||||
Registry().register('service_list', MagicMock())
|
||||
Registry().register('main_window', MagicMock())
|
||||
|
@ -32,7 +32,7 @@ import pytest
|
||||
from openlp.plugins.songs.lib.openlyricsexport import OpenLyricsExport
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
@pytest.fixture
|
||||
def temp_folder():
|
||||
temp_path = Path(mkdtemp())
|
||||
yield temp_path
|
||||
|
@ -33,7 +33,7 @@ sample_theme_data = {'file_name': 'BlueBurst.otz', 'sha256': 'sha_256_hash',
|
||||
'thumbnail': 'BlueBurst.png', 'title': 'Blue Burst'}
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def mocked_set_icon(mock_settings):
|
||||
move_to_thread_patcher = patch('openlp.core.ui.firsttimeform.DownloadWorker.moveToThread').start()
|
||||
set_icon_patcher = patch('openlp.core.ui.firsttimeform.ThemeListWidgetItem.setIcon').start()
|
||||
|
@ -29,7 +29,7 @@ from PyQt5 import QtCore, QtTest, QtWidgets
|
||||
from openlp.plugins.custom.forms.editcustomform import EditCustomForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
media_item = MagicMock()
|
||||
|
@ -30,7 +30,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
Registry().register('main_window', main_window)
|
||||
|
@ -30,7 +30,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.plugins.images.forms.choosegroupform import ChooseGroupForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
Registry().register('main_window', main_window)
|
||||
|
@ -36,7 +36,7 @@ if os.name == 'nt' and not get_vlc():
|
||||
raise SkipTest('Windows without VLC, skipping this test since it cannot run without vlc')
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
vlc_patcher = patch('openlp.plugins.media.forms.mediaclipselectorform.get_vlc')
|
||||
|
@ -30,7 +30,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.plugins.songs.forms.authorsform import AuthorsForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
Registry().register('main_window', main_window)
|
||||
|
@ -31,7 +31,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.plugins.songs.forms.editsongform import EditSongForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
Registry().register('main_window', main_window)
|
||||
|
@ -29,7 +29,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.plugins.songs.forms.editverseform import EditVerseForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
Registry().register('main_window', main_window)
|
||||
|
@ -31,7 +31,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.plugins.songs.forms.songmaintenanceform import SongMaintenanceForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form_env(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
Registry().register('main_window', main_window)
|
||||
|
@ -29,7 +29,7 @@ from openlp.core.common.registry import Registry
|
||||
from openlp.plugins.songs.forms.topicsform import TopicsForm
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def form(settings):
|
||||
main_window = QtWidgets.QMainWindow()
|
||||
Registry().register('main_window', main_window)
|
||||
|
@ -27,7 +27,7 @@ from openlp.core.projectors.pjlink import PJLink
|
||||
from tests.resources.projector.data import TEST1_DATA
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def pjlink():
|
||||
pj_link = PJLink(Projector(**TEST1_DATA), no_poll=True)
|
||||
yield pj_link
|
||||
|
@ -102,7 +102,7 @@ def test_upgrade_old_projector_db(temp_folder):
|
||||
assert updated_to_version == latest_version, 'The projector DB should have been upgrade to the latest version'
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def projector(temp_folder, settings):
|
||||
"""
|
||||
Set up anything necessary for all tests
|
||||
|
@ -30,7 +30,7 @@ from openlp.core.projectors.editform import ProjectorEditForm
|
||||
from tests.resources.projector.data import TEST1_DATA, TEST_DB
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def projector_form(settings):
|
||||
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
|
||||
mocked_init_url.return_value = 'sqlite:///' + TEST_DB
|
||||
|
@ -34,7 +34,7 @@ from openlp.core.projectors.sourceselectform import SourceSelectSingle, source_g
|
||||
from tests.resources.projector.data import TEST1_DATA, TEST_DB
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def projector_env(settings):
|
||||
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
|
||||
mocked_init_url.return_value = 'sqlite:///{}'.format(TEST_DB)
|
||||
|
@ -30,7 +30,7 @@ from openlp.core.projectors.manager import ProjectorManager
|
||||
from tests.resources.projector.data import TEST_DB
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
@pytest.fixture()
|
||||
def projector_manager(settings):
|
||||
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
|
||||
mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
|
||||
|
Loading…
Reference in New Issue
Block a user