From 9aea8985fb38ff81cda1c7cb41ca5c4fe0fdd27b Mon Sep 17 00:00:00 2001 From: William Grant Date: Wed, 16 Mar 2011 23:03:52 +1100 Subject: [PATCH] Support multiple test modules. --- .testr.conf | 2 +- README | 2 +- dkim/tests/__init__.py | 30 ++++++++++++++++++++++++++++++ dkim/tests/test_dkim.py | 5 +++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.testr.conf b/.testr.conf index 3f13aff..dc137c2 100644 --- a/.testr.conf +++ b/.testr.conf @@ -1,4 +1,4 @@ [DEFAULT] -test_command=PYTHONPATH=. python -m subunit.run $LISTOPT $IDOPTION dkim.tests.test_dkim +test_command=PYTHONPATH=. python -m subunit.run $LISTOPT $IDOPTION dkim.tests.test_suite test_id_option=--load-list $IDFILE test_list_option=--list diff --git a/README b/README index cebb3e1..12284cc 100644 --- a/README +++ b/README @@ -25,7 +25,7 @@ TESTING To run pydkim's test suite: - PYTHONPATH=. python dkim/tests/test_dkim.py + PYTHONPATH=. python -m unittest dkim.tests.test_suite Alternatively, if you have testrepository installed: diff --git a/dkim/tests/__init__.py b/dkim/tests/__init__.py index e69de29..fad9629 100644 --- a/dkim/tests/__init__.py +++ b/dkim/tests/__init__.py @@ -0,0 +1,30 @@ +# This software is provided 'as-is', without any express or implied +# warranty. In no event will the author be held liable for any damages +# arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not +# claim that you wrote the original software. If you use this software +# in a product, an acknowledgment in the product documentation would be +# appreciated but is not required. +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# 3. This notice may not be removed or altered from any source distribution. +# +# Copyright (c) 2011 William Grant + +import unittest + + +def test_suite(): + from dkim.tests import ( + test_dkim, + ) + modules = [ + test_dkim, + ] + suites = map(lambda x: x.test_suite(), modules) + return unittest.TestSuite(suites) diff --git a/dkim/tests/test_dkim.py b/dkim/tests/test_dkim.py index 9d6a2e6..f4ca775 100644 --- a/dkim/tests/test_dkim.py +++ b/dkim/tests/test_dkim.py @@ -112,5 +112,6 @@ class TestParseTagValue(unittest.TestCase): parse_tag_value, 'foo=bar;foo=baz') -if __name__ == '__main__': - unittest.main() +def test_suite(): + from unittest import TestLoader + return TestLoader().loadTestsFromName(__name__)