PN := dunshire
-SRCDIR := src/$(PN)
-TESTDIR := src/test
-SRCS := $(SRCDIR)/*.py
+SRCS := src/$(PN)/*.py src/test/*.py
doc: $(SRCS) doc/source/conf.py doc/makefile
cd doc && $(MAKE) html
.PHONY: check
check:
- PYTHONPATH=src python $(TESTDIR)/suite.py
+ PYTHONPATH=src python src/test/suite.py
.PHONY: lint
lint:
.PHONY: clean
clean:
- rm -rf $(SRCDIR)/__pycache__ $(TESTDIR)/__pycache__ doc/build
+ rm -rf src/$(PN)/__pycache__ src/test/__pycache__ doc/build
from unittest import TestLoader, TestSuite, TextTestRunner
from doctest import DocTestSuite
-# Add '../' to our path.
-from site import addsitedir
-addsitedir('./src')
from dunshire import cones
from dunshire import errors
from dunshire import matrices
from dunshire import games
from test import symmetric_linear_game_test
-if __name__ == '__main__':
+def run_suite():
+ """
+ Run all of the unit and doctests for the ``dunshire`` and ``test``
+ packages.
+ """
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))
- suite.addTest(TestLoader().loadTestsFromModule(symmetric_linear_game_test))
+ slg_tests = TestLoader().loadTestsFromModule(symmetric_linear_game_test)
+ suite.addTest(slg_tests)
runner = TextTestRunner(verbosity=1)
runner.run(suite)
+
+if __name__ == '__main__':
+ run_suite()
-# These few are used only for tests.
+"""
+Unit tests for the :class:`SymmetricLinearGame` class.
+"""
+
from math import sqrt
from random import randint, uniform
from unittest import TestCase
self.assertTrue(abs(first - second) < options.ABS_TOL)
- def assert_norm_within_tol(self, first, second):
- """
- Test that ``first`` and ``second`` vectors are equal in the
- sense that the norm of their difference is within our default
- tolerance.
- """
- self.assert_within_tol(norm(first - second), 0)
-
-
def assert_solution_exists(self, L, K, e1, e2):
"""
Given the parameters needed to construct a SymmetricLinearGame,