4 if len(sys
.argv
)>1 and sys
.argv
[1].lower() == 'gevent':
5 from gevent
import monkey
14 from os
.path
import splitext
, basename
, join
as pjoin
19 Find and run all tests in the tests/ directory.
21 Excludes live tests (tests/live_*).
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])
31 for file in testfiles
:
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)
42 result
= runner
.run(tests
)
46 # Add a 'test' command for setup.py
48 class TestCommand(distutils
.core
.Command
):
52 def initialize_options(self
):
53 self
._dir
= os
.getcwd()
55 def finalize_options(self
):
62 if __name__
== '__main__':
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
))