forked from openlp/openlp
Start of the testing framework
bzr-revno: 1736
This commit is contained in:
commit
1e4870ddb9
@ -261,8 +261,10 @@ def main(args=None):
|
||||
app.setApplicationName(u'OpenLP')
|
||||
app.setApplicationVersion(get_application_version()[u'version'])
|
||||
# Instance check
|
||||
if app.isAlreadyRunning():
|
||||
sys.exit()
|
||||
if not options.testing:
|
||||
# Instance check
|
||||
if app.isAlreadyRunning():
|
||||
sys.exit()
|
||||
# First time checks in settings
|
||||
if not QtCore.QSettings().value(u'general/has run wizard',
|
||||
QtCore.QVariant(False)).toBool():
|
||||
@ -284,5 +286,7 @@ def main(args=None):
|
||||
# Do not run method app.exec_() when running gui tests
|
||||
if options.testing:
|
||||
app.run(qt_args, testing=True)
|
||||
# For gui tests we need access to window intances and their components
|
||||
return app
|
||||
else:
|
||||
sys.exit(app.run(qt_args))
|
||||
|
@ -80,6 +80,7 @@ OPTIONAL_MODULES = [
|
||||
('sqlite', ' (SQLite 2 support)'),
|
||||
('MySQLdb', ' (MySQL support)'),
|
||||
('psycopg2', ' (PostgreSQL support)'),
|
||||
('pytest', ' (testing framework)'),
|
||||
]
|
||||
|
||||
w = sys.stdout.write
|
||||
|
45
testing/conftest.py
Normal file
45
testing/conftest.py
Normal file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
|
||||
# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
"""
|
||||
Configuration file for pytest framework.
|
||||
"""
|
||||
|
||||
from openlp.core import main as openlp_main
|
||||
|
||||
|
||||
# Test function argument to make openlp gui instance persistent for all tests.
|
||||
# All test cases have to access the same instance. To allow create multiple
|
||||
# instances it would be necessary use diffrent configuraion and data files.
|
||||
# Created instance will use your OpenLP settings.
|
||||
def pytest_funcarg__openlpapp(request):
|
||||
def setup():
|
||||
return openlp_main(['--testing'])
|
||||
def teardown(app):
|
||||
pass
|
||||
return request.cached_setup(setup=setup, teardown=teardown, scope='session')
|
59
testing/run.py
Executable file
59
testing/run.py
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
|
||||
# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
"""
|
||||
This script is used to run set of automated tests of OpenLP. To start tests,
|
||||
simply run this script::
|
||||
|
||||
@:~$ ./run.py
|
||||
|
||||
"""
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
TESTS_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
SRC_PATH = os.path.join(TESTS_PATH, '..')
|
||||
|
||||
PYTEST_OPTIONS = [TESTS_PATH]
|
||||
|
||||
# Extend python PATH with openlp source
|
||||
sys.path.insert(0, SRC_PATH)
|
||||
|
||||
# Python testing framework
|
||||
# http://pytest.org
|
||||
import pytest
|
||||
|
||||
|
||||
def main():
|
||||
print 'pytest options:', PYTEST_OPTIONS
|
||||
pytest.main(PYTEST_OPTIONS)
|
||||
|
||||
|
||||
if __name__ == u'__main__':
|
||||
main()
|
36
testing/test_app.py
Normal file
36
testing/test_app.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
|
||||
# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias #
|
||||
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
from openlp.core import OpenLP
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
|
||||
|
||||
def test_start_app(openlpapp):
|
||||
assert type(openlpapp) == OpenLP
|
||||
assert type(openlpapp.mainWindow) == MainWindow
|
||||
assert unicode(openlpapp.mainWindow.windowTitle()) == u'OpenLP 2.0'
|
Loading…
Reference in New Issue
Block a user