From: Michael Orlitzky Date: Sun, 16 Oct 2016 04:51:24 +0000 (-0400) Subject: Pylint cleanup for tests. X-Git-Tag: 0.1.0~121 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=dd7758c84633a2c72b164e440078ab737abea701;p=dunshire.git Pylint cleanup for tests. --- diff --git a/makefile b/makefile index e48e9a0..7fe104e 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,5 @@ 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 @@ -12,7 +10,7 @@ doctest: .PHONY: check check: - PYTHONPATH=src python $(TESTDIR)/suite.py + PYTHONPATH=src python src/test/suite.py .PHONY: lint lint: @@ -20,4 +18,4 @@ lint: .PHONY: clean clean: - rm -rf $(SRCDIR)/__pycache__ $(TESTDIR)/__pycache__ doc/build + rm -rf src/$(PN)/__pycache__ src/test/__pycache__ doc/build diff --git a/src/test/suite.py b/src/test/suite.py index 078d0c9..e10c38d 100644 --- a/src/test/suite.py +++ b/src/test/suite.py @@ -8,22 +8,27 @@ codebase into one big TestSuite() and the runs it. 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() diff --git a/src/test/symmetric_linear_game_test.py b/src/test/symmetric_linear_game_test.py index f6f397f..647d013 100644 --- a/src/test/symmetric_linear_game_test.py +++ b/src/test/symmetric_linear_game_test.py @@ -1,4 +1,7 @@ -# 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 @@ -251,15 +254,6 @@ class SymmetricLinearGameTest(TestCase): # pylint: disable=R0904 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,