Commit ce84db39 authored by Denis Bilenko's avatar Denis Bilenko

test__doctests.py: test setup.py too

parent 82eff8f5
......@@ -2,39 +2,49 @@ import os
import re
import doctest
import unittest
from os.path import join, dirname
import gevent
from gevent import socket
base = os.path.dirname(gevent.__file__)
modules = set()
modules.add(('setup', 'setup.py'))
def myfunction(*args, **kwargs):
pass
globs = {'myfunction': myfunction, 'gevent': gevent, 'socket': socket}
for path, dirs, files in os.walk(base):
package = 'gevent' + path.replace(base, '').replace('/', '.')
modules.add((package, os.path.join(path, '__init__.py')))
for f in files:
module = None
if f.endswith('.py'):
module = f[:-3]
if module:
modules.add((package + '.' + module, os.path.join(path, f)))
suite = unittest.TestSuite()
tests_count = 0
modules_count = 0
for m, path in modules:
if re.search('^\s*>>> ', open(path).read(), re.M):
s = doctest.DocTestSuite(m, extraglobs=globs)
print '%s (from %s): %s tests' % (m, path, len(s._tests))
suite.addTest(s)
modules_count += 1
tests_count += len(s._tests)
if __name__ == '__main__':
print 'Total: %s tests in %s modules' % (tests_count, modules_count)
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite)
cwd = os.getcwd()
try:
base = dirname(gevent.__file__)
print base
os.chdir(join(base, '..'))
globs = {'myfunction': myfunction, 'gevent': gevent, 'socket': socket}
for path, dirs, files in os.walk(base):
package = 'gevent' + path.replace(base, '').replace('/', '.')
modules.add((package, join(path, '__init__.py')))
for f in files:
module = None
if f.endswith('.py'):
module = f[:-3]
if module:
modules.add((package + '.' + module, join(path, f)))
suite = unittest.TestSuite()
tests_count = 0
modules_count = 0
for m, path in modules:
if re.search('^\s*>>> ', open(path).read(), re.M):
s = doctest.DocTestSuite(m, extraglobs=globs)
print '%s (from %s): %s tests' % (m, path, len(s._tests))
suite.addTest(s)
modules_count += 1
tests_count += len(s._tests)
print 'Total: %s tests in %s modules' % (tests_count, modules_count)
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite)
finally:
os.chdir(cwd)
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