Make connect(), abort() and reconnect() work
[slixmpp.git] / testall.py
blob2cb6f538cdcf8978cac8ebe4acc0ae5ffba8ee5b
1 #!/usr/bin/env python
3 import sys
4 if len(sys.argv)>1 and sys.argv[1].lower() == 'gevent':
5 from gevent import monkey
6 monkey.patch_all()
8 import os
9 import logging
10 import unittest
11 import distutils.core
13 from glob import glob
14 from os.path import splitext, basename, join as pjoin
17 def run_tests():
18 """
19 Find and run all tests in the tests/ directory.
21 Excludes live tests (tests/live_*).
22 """
23 testfiles = ['tests.test_overall']
24 exclude = ['__init__.py', 'test_overall.py']
25 for t in glob(pjoin('tests', '*.py')):
26 if True not in [t.endswith(ex) for ex in exclude]:
27 if basename(t).startswith('test_'):
28 testfiles.append('tests.%s' % splitext(basename(t))[0])
30 suites = []
31 for file in testfiles:
32 __import__(file)
33 suites.append(sys.modules[file].suite)
35 tests = unittest.TestSuite(suites)
36 runner = unittest.TextTestRunner(verbosity=2)
38 # Disable logging output
39 logging.basicConfig(level=100)
40 logging.disable(100)
42 result = runner.run(tests)
43 return result
46 # Add a 'test' command for setup.py
48 class TestCommand(distutils.core.Command):
50 user_options = [ ]
52 def initialize_options(self):
53 self._dir = os.getcwd()
55 def finalize_options(self):
56 pass
58 def run(self):
59 run_tests()
62 if __name__ == '__main__':
63 result = run_tests()
64 print("<tests %s ran='%s' errors='%s' fails='%s' success='%s' gevent_enabled=%s/>" % (
65 "xmlns='http//andyet.net/protocol/tests'",
66 result.testsRun, len(result.errors),
67 len(result.failures), result.wasSuccessful(),'gevent' in sys.modules))