From 7382c48a9bfeecd5a0b30cc4a77e2b0ade138c48 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sat, 7 Mar 2009 20:58:55 +1100 Subject: Write some fiction. --- lib/testscenarios/__init__.py | 43 +++++++++++++++++++++++++++++++++++++ lib/testscenarios/tests/__init__.py | 35 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 lib/testscenarios/__init__.py create mode 100644 lib/testscenarios/tests/__init__.py (limited to 'lib') diff --git a/lib/testscenarios/__init__.py b/lib/testscenarios/__init__.py new file mode 100644 index 0000000..a4f338d --- /dev/null +++ b/lib/testscenarios/__init__.py @@ -0,0 +1,43 @@ +# testscenarios: extensions to python unittest to allow declarative +# dependency injection ('scenarios') by tests. +# Copyright (C) 2009 Robert Collins +# +# 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; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# + +"""Support for running tests with different scenarios declaratively + +Testscenarios provides clean dependency injection for python unittest style +tests. This can be used for interface testing (testing many implementations via +a single test suite) or for classic dependency injection (provide tests with +dependencies externally to the test code itself, allowing easy testing in +different situations). + +See the README for a manual, and the docstrings on individual functions and +methods for details. +""" + + +import unittest + + +def test_suite(): + import testscenarios.tests + return testscenarios.tests.test_suite() + + +def load_tests(standard_tests, module, loader): + standard_tests.addTests(loader.loadTestsFromNames(["testscenarios.tests"])) + return standard_tests diff --git a/lib/testscenarios/tests/__init__.py b/lib/testscenarios/tests/__init__.py new file mode 100644 index 0000000..98cfb11 --- /dev/null +++ b/lib/testscenarios/tests/__init__.py @@ -0,0 +1,35 @@ +# testscenarios: extensions to python unittest to allow declarative +# dependency injection ('scenarios') by tests. +# Copyright (C) 2009 Robert Collins +# +# 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; either version 2 of the License, or +# (at your option) any later version. +# +# 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 +# + +import unittest + +import testscenarios + + +def test_suite(): + result = unittest.TestSuite() + return result + + +def load_tests(standard_tests, module, loader): + test_modules = [] + prefix = "testscenarios.tests.test_" + test_mod_names = [prefix + test_module for test_module in test_modules] + standard_tests.addTests(loader.loadTestsFromNames(test_mod_names)) + return standard_tests -- cgit v1.2.1