提交 a9f04767 authored 作者: Olivier Breuleux's avatar Olivier Breuleux

fixed tests

上级 ff223c73
import unittest, os, sys, traceback
def test_root_dir(debugmode=False): import unittest, os, sys, traceback, commands
def test_module(module_path, debugmode = False):
files = commands.getoutput("find %s -name test_*.py" % module_path)
suite = None suite = None
filenames = os.listdir('.') for file in files.split("\n"):
for filename in filenames: try:
if filename[-3:] == '.py' and filename[0:5] == '_test': module = __import__(file[:-3])
#print >>sys.stderr, 'Loading', modname except Exception, e:
modname = filename[0:-3] print >>sys.stderr, "===================================================="
print >>sys.stderr, "Failed to load %s" % file
try: print >>sys.stderr, "===================================================="
module = __import__(modname) traceback.print_exc()
except Exception, e: print >>sys.stderr, "===================================================="
print >>sys.stderr, "====================================================" continue
print >>sys.stderr, "Failed to load %s.py" % modname
print >>sys.stderr, "====================================================" tests = unittest.TestLoader().loadTestsFromModule(module)
traceback.print_exc() if tests.countTestCases() > 0:
print >>sys.stderr, "====================================================" print >>sys.stderr, 'Testing', file
continue if suite is None:
suite = tests
tests = unittest.TestLoader().loadTestsFromModule(module) else:
if tests.countTestCases() > 0: suite.addTests(tests)
print >>sys.stderr, 'Testing', modname
if suite is None:
suite = tests
else:
suite.addTests(tests)
if debugmode: if debugmode:
suite.debug() suite.debug()
else: else:
unittest.TextTestRunner(verbosity=1).run(suite) unittest.TextTestRunner(verbosity=1).run(suite)
if __name__ == '__main__': if __name__ == '__main__':
def printUsage(): def printUsage():
...@@ -47,13 +46,6 @@ if __name__ == '__main__': ...@@ -47,13 +46,6 @@ if __name__ == '__main__':
elif len(sys.argv)>2: elif len(sys.argv)>2:
printUsage() printUsage()
if len(sys.argv) >= 2: test_module("theano")
cmd = sys.argv[1]
else:
cmd = 'python'
for dir in 'gof compile scalar tensor sparse'.split():
os.system('cd %s; %s autotest.py %s' % (dir, cmd, debugparam))
test_root_dir(debugparam!="")
import unittest import unittest
from link import PerformLinker, Profiler from theano.gof.link import PerformLinker, Profiler
from cc import * from theano.gof.cc import *
from type import Type from theano.gof.type import Type
from graph import Result, Apply, Constant from theano.gof.graph import Result, Apply, Constant
from op import Op from theano.gof.op import Op
import env from theano.gof import env
import toolbox from theano.gof import toolbox
def as_result(x): def as_result(x):
assert isinstance(x, Result) assert isinstance(x, Result)
......
import unittest import unittest
from type import Type from theano.gof.type import Type
import graph from theano.gof import graph
from graph import Result, Apply from theano.gof.graph import Result, Apply
from op import Op from theano.gof.op import Op
from opt import * from theano.gof.opt import *
import destroyhandler from theano.gof import destroyhandler
from env import Env, InconsistencyError from theano.gof.env import Env, InconsistencyError
from toolbox import ReplaceValidate from theano.gof.toolbox import ReplaceValidate
from copy import copy from copy import copy
......
from collections import deque from collections import deque
import unittest import unittest
from graph import * from theano.gof.graph import *
from op import Op from theano.gof.op import Op
from type import Type from theano.gof.type import Type
from graph import Result from theano.gof.graph import Result
if 1: if 1:
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
import unittest import unittest
import graph from theano.gof import graph
from graph import Result, Apply, Constant from theano.gof.graph import Result, Apply, Constant
from type import Type from theano.gof.type import Type
from op import Op from theano.gof.op import Op
import env from theano.gof import env
import toolbox from theano.gof import toolbox
from link import * from theano.gof.link import *
#from _test_result import Double #from _test_result import Double
......
import unittest import unittest
from copy import copy from copy import copy
from op import * from theano.gof.op import *
from type import Type, Generic from theano.gof.type import Type, Generic
from graph import Apply, Result from theano.gof.graph import Apply, Result
def as_result(x): def as_result(x):
assert isinstance(x, Result) assert isinstance(x, Result)
......
import unittest import unittest
from type import Type from theano.gof.type import Type
from graph import Result, Apply, Constant from theano.gof.graph import Result, Apply, Constant
from op import Op from theano.gof.op import Op
from opt import * from theano.gof.opt import *
from env import Env from theano.gof.env import Env
from toolbox import * from theano.gof.toolbox import *
def as_result(x): def as_result(x):
......
import unittest import unittest
from graph import Result, Apply from theano.gof.graph import Result, Apply
from type import Type from theano.gof.type import Type
from op import Op from theano.gof.op import Op
from env import Env, InconsistencyError from theano.gof.env import Env, InconsistencyError
from toolbox import * from theano.gof.toolbox import *
def as_result(x): def as_result(x):
......
import unittest import unittest
from type import * from theano.gof.type import *
# todo: test generic # todo: test generic
......
...@@ -2,5 +2,4 @@ ...@@ -2,5 +2,4 @@
from basic import * from basic import *
from basic import _abs from basic import _abs
import opt
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
# #
import unittest import unittest
import numpy import numpy
import gof from theano import gof
from gradient import * from theano.gradient import *
import gradient from theano import gradient
class _test_grad_sources_inputs(unittest.TestCase): class _test_grad_sources_inputs(unittest.TestCase):
def test_retNone1(self): def test_retNone1(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论