forked from openlp/openlp
old test code
This commit is contained in:
parent
eac2ce39b3
commit
d491997ca7
@ -60,10 +60,10 @@ class Registry(object):
|
||||
registry = cls()
|
||||
registry.service_list = {}
|
||||
registry.functions_list = {}
|
||||
registry.running_under_test = False
|
||||
registry.running_under_test = True
|
||||
# Allow the tests to remove Registry entries but not the live system
|
||||
if u'nosetest' in sys.argv[0]:
|
||||
registry.running_under_test = True
|
||||
if u'openlp.py' in sys.argv[0]:
|
||||
registry.running_under_test = False
|
||||
return registry
|
||||
|
||||
def get(self, key):
|
||||
@ -127,8 +127,20 @@ class Registry(object):
|
||||
for function in self.functions_list[event]:
|
||||
try:
|
||||
result = function(*args, **kwargs)
|
||||
# allow the result to be viewed in tests only.
|
||||
if self.running_under_test is True:
|
||||
self.inspect_result(result,*args, **kwargs)
|
||||
if result:
|
||||
results.append(result)
|
||||
except TypeError:
|
||||
# Who has called me can help
|
||||
import inspect
|
||||
log.debug(inspect.currentframe().f_back.f_locals)
|
||||
log.exception(u'Exception for function %s', function)
|
||||
return results
|
||||
|
||||
def inspect_result(self, results,*args, **kwargs):
|
||||
"""
|
||||
Dummy method for tests to inspect the results of a call.
|
||||
"""
|
||||
pass
|
||||
|
@ -1,46 +0,0 @@
|
||||
#!/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, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Edwin Lunando, 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 #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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')
|
@ -49,7 +49,7 @@ class TestRegistry(TestCase):
|
||||
|
||||
def registry_function_test(self):
|
||||
"""
|
||||
Test the registry creation and its usage
|
||||
Test the registry function creation and their usages
|
||||
"""
|
||||
# GIVEN: An existing registry register a function
|
||||
Registry.create()
|
||||
|
60
tests/run.py
60
tests/run.py
@ -1,60 +0,0 @@
|
||||
#!/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, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Edwin Lunando, 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 #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
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()
|
@ -1,37 +0,0 @@
|
||||
#!/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, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Edwin Lunando, 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 #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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.1'
|
Loading…
Reference in New Issue
Block a user