]> gitweb.michael.orlitzky.com - dunshire.git/blobdiff - test/__init__.py
Add setup.py and reorganize everything to make its "test" command happy.
[dunshire.git] / test / __init__.py
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644 (file)
index 0000000..6942bf2
--- /dev/null
@@ -0,0 +1,39 @@
+"""
+The whole test suite.
+
+This module compiles the doctests and unittests from the rest of the
+codebase into one big TestSuite() and the runs it. It also provides a
+function :func:`build_suite` that merely builds the suite; the result
+can be used by setuptools.
+"""
+
+from unittest import TestLoader, TestSuite, TextTestRunner
+from doctest import DocTestSuite
+
+from dunshire import cones
+from dunshire import errors
+from dunshire import matrices
+from dunshire import games
+from test import symmetric_linear_game_test
+
+def build_suite():
+    """
+    Build our test suite, separately from running it.
+    """
+    suite = TestSuite()
+    suite.addTest(DocTestSuite(cones))
+    suite.addTest(DocTestSuite(errors))
+    suite.addTest(DocTestSuite(matrices))
+    suite.addTest(DocTestSuite(games))
+    suite.addTest(DocTestSuite(symmetric_linear_game_test))
+    slg_tests = TestLoader().loadTestsFromModule(symmetric_linear_game_test)
+    suite.addTest(slg_tests)
+    return suite
+
+def run_suite(s):
+    """
+    Run all of the unit and doctests for the ``dunshire`` and ``test``
+    packages.
+    """
+    runner = TextTestRunner(verbosity=1)
+    runner.run(s)