From d491997ca788c414fafde264bec9581373e37a54 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 6 Feb 2013 19:25:16 +0000 Subject: [PATCH] old test code --- openlp/core/lib/registry.py | 18 +++++- tests/conftest.py | 46 -------------- .../openlp_core_lib/test_registry.py | 2 +- tests/run.py | 60 ------------------- tests/test_app.py | 37 ------------ 5 files changed, 16 insertions(+), 147 deletions(-) delete mode 100644 tests/conftest.py delete mode 100755 tests/run.py delete mode 100644 tests/test_app.py diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index a206e950a..f9773a6d1 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index 5722c6235..000000000 --- a/tests/conftest.py +++ /dev/null @@ -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') diff --git a/tests/functional/openlp_core_lib/test_registry.py b/tests/functional/openlp_core_lib/test_registry.py index 32ad1b8e4..826aafc9b 100644 --- a/tests/functional/openlp_core_lib/test_registry.py +++ b/tests/functional/openlp_core_lib/test_registry.py @@ -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() diff --git a/tests/run.py b/tests/run.py deleted file mode 100755 index 53a6a6cb6..000000000 --- a/tests/run.py +++ /dev/null @@ -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() diff --git a/tests/test_app.py b/tests/test_app.py deleted file mode 100644 index c0b1e651a..000000000 --- a/tests/test_app.py +++ /dev/null @@ -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'