From bf1f79c5712c9f4dc95a68af238b1857f70d977b Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Wed, 18 Jan 2012 22:41:05 +0100 Subject: [PATCH] Add "test" command to setup.py "python setup.py test" will now run the complete test suite. Remove the previous ./test command. Signed-off-by: Sebastian Spaeth --- setup.py | 30 ++++++++++++++++++++++++++---- test/README | 3 ++- test/test | 10 ---------- test/tests/test_01_basic.py | 6 +----- 4 files changed, 29 insertions(+), 20 deletions(-) delete mode 100755 test/test diff --git a/setup.py b/setup.py index c87077b..e684cda 100644 --- a/setup.py +++ b/setup.py @@ -20,11 +20,32 @@ # 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 -# END OF COPYRIGHT # - -from distutils.core import setup +import os +from distutils.core import setup, Command import offlineimap +import logging +from test.OLItest import OLITextTestRunner, TestLoader, OLITestLib + +class TestCommand(Command): + """runs the OLI testsuite""" + description = "Runs the test suite" + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + logging.basicConfig(format='%(message)s') + # set credentials and OfflineImap command to be executed: + OLITestLib(cred_file='./test/credentials.conf', cmd='./offlineimap.py') + suite = TestLoader().discover('./test/tests') + #TODO: failfast does not seem to exist in python2.6? + OLITextTestRunner(verbosity=2,failfast=True).run(suite) + setup(name = "offlineimap", version = offlineimap.__version__, @@ -36,6 +57,7 @@ setup(name = "offlineimap", 'offlineimap.repository', 'offlineimap.ui'], scripts = ['bin/offlineimap'], license = offlineimap.__copyright__ + \ - ", Licensed under the GPL version 2" + ", Licensed under the GPL version 2", + cmdclass = { 'test': TestCommand} ) diff --git a/test/README b/test/README index 3bf6694..a02e3b9 100644 --- a/test/README +++ b/test/README @@ -9,7 +9,8 @@ How to run the tests will change the account and upload/delete/modify it's contents and folder structure. So don't use a real used account here... -- Execute './test' +- go to the top level dir (one above this one) and execute: + 'python setup.py test' System requirements =================== diff --git a/test/test b/test/test deleted file mode 100755 index 1394058..0000000 --- a/test/test +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python -import logging -from OLItest import OLITextTestRunner, TestLoader, OLITestLib - -if __name__ == '__main__': - logging.basicConfig(format='%(message)s') - # set credentials and OfflineImap command to be executed: - OLITestLib(cred_file='./credentials.conf', cmd='../offlineimap.py') - suite = TestLoader().discover('./tests') - OLITextTestRunner(verbosity=2).run(suite) diff --git a/test/tests/test_01_basic.py b/test/tests/test_01_basic.py index 7f30052..cb6d293 100644 --- a/test/tests/test_01_basic.py +++ b/test/tests/test_01_basic.py @@ -17,11 +17,7 @@ import random import unittest import logging import os, sys -# Insert ".." into the python search path to get OLItest -cmd_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -if cmd_folder not in sys.path: - sys.path.insert(0, cmd_folder) -from OLItest import OLITestLib +from test.OLItest import OLITestLib def setUpModule(): logging.info("Set Up test module %s" % __name__)