Commit 4c87728b authored by Denis Bilenko's avatar Denis Bilenko

test__doctests.py: skip modules that cannot be imported

parent ebfc95fd
...@@ -3,7 +3,7 @@ import os ...@@ -3,7 +3,7 @@ import os
import re import re
import doctest import doctest
import unittest import unittest
from os.path import join, dirname import traceback
import gevent import gevent
from gevent import socket from gevent import socket
from greentest import walk_modules from greentest import walk_modules
...@@ -19,7 +19,7 @@ if __name__ == '__main__': ...@@ -19,7 +19,7 @@ if __name__ == '__main__':
try: try:
allowed_modules = sys.argv[1:] allowed_modules = sys.argv[1:]
sys.path.append('.') sys.path.append('.')
base = dirname(gevent.__file__) base = os.path.dirname(gevent.__file__)
print base print base
os.chdir('..') os.chdir('..')
...@@ -44,11 +44,15 @@ if __name__ == '__main__': ...@@ -44,11 +44,15 @@ if __name__ == '__main__':
modules_count = 0 modules_count = 0
for m, path in modules: for m, path in modules:
if re.search('^\s*>>> ', open(path).read(), re.M): if re.search('^\s*>>> ', open(path).read(), re.M):
try:
s = doctest.DocTestSuite(m, extraglobs=globs) s = doctest.DocTestSuite(m, extraglobs=globs)
print '%s (from %s): %s tests' % (m, path, len(s._tests)) print '%s (from %s): %s tests' % (m, path, len(s._tests))
suite.addTest(s) suite.addTest(s)
modules_count += 1 modules_count += 1
tests_count += len(s._tests) tests_count += len(s._tests)
except Exception:
traceback.print_exc()
sys.stderr.write('Failed to process %s\n\n' % path)
print 'Total: %s tests in %s modules' % (tests_count, modules_count) print 'Total: %s tests in %s modules' % (tests_count, modules_count)
runner = unittest.TextTestRunner(verbosity=2) runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite) runner.run(suite)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment