summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2009-03-07 20:58:55 +1100
committerRobert Collins <robertc@robertcollins.net>2009-03-07 20:58:55 +1100
commit7382c48a9bfeecd5a0b30cc4a77e2b0ade138c48 (patch)
tree5a1bd152e22ef189e932557901a581593aec37c4 /lib
downloadtestscenarios-7382c48a9bfeecd5a0b30cc4a77e2b0ade138c48.tar.gz
Write some fiction.
Diffstat (limited to 'lib')
-rw-r--r--lib/testscenarios/__init__.py43
-rw-r--r--lib/testscenarios/tests/__init__.py35
2 files changed, 78 insertions, 0 deletions
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 <robertc@robertcollins.net>
+#
+# 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 <robertc@robertcollins.net>
+#
+# 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