提交 8ef9a3f0 authored 作者: Frederic Bastien's avatar Frederic Bastien

backport test to python24

上级 318dbf63
...@@ -655,10 +655,11 @@ class T_max_and_argmax(unittest.TestCase): ...@@ -655,10 +655,11 @@ class T_max_and_argmax(unittest.TestCase):
oldlevel = _logger.getEffectiveLevel() oldlevel = _logger.getEffectiveLevel()
_logger.setLevel(logging.CRITICAL) _logger.setLevel(logging.CRITICAL)
try: try:
eval_outputs(max_and_argmax(n,3)) try:
assert False eval_outputs(max_and_argmax(n,3))
except ValueError, e: assert False
pass except ValueError, e:
pass
finally: finally:
_logger.setLevel(oldlevel) _logger.setLevel(oldlevel)
def test2_invalid_neg(self): def test2_invalid_neg(self):
...@@ -666,10 +667,11 @@ class T_max_and_argmax(unittest.TestCase): ...@@ -666,10 +667,11 @@ class T_max_and_argmax(unittest.TestCase):
old_stderr = sys.stderr old_stderr = sys.stderr
sys.stderr = StringIO.StringIO() sys.stderr = StringIO.StringIO()
try: try:
eval_outputs(max_and_argmax(n,-3)) try:
assert False eval_outputs(max_and_argmax(n,-3))
except ValueError, e: assert False
pass except ValueError, e:
pass
finally: finally:
sys.stderr = old_stderr sys.stderr = old_stderr
def test2_valid_neg(self): def test2_valid_neg(self):
...@@ -726,11 +728,12 @@ class T_subtensor(unittest.TestCase): ...@@ -726,11 +728,12 @@ class T_subtensor(unittest.TestCase):
oldlevel = _logger.getEffectiveLevel() oldlevel = _logger.getEffectiveLevel()
_logger.setLevel(logging.CRITICAL) _logger.setLevel(logging.CRITICAL)
try: try:
tval = eval_outputs([t]) try:
assert 0 tval = eval_outputs([t])
except Exception, e: assert 0
if e[0] != 'index out of bounds': except Exception, e:
raise if e[0] != 'index out of bounds':
raise
finally: finally:
_logger.setLevel(oldlevel) _logger.setLevel(oldlevel)
def test1_err_subslice(self): def test1_err_subslice(self):
...@@ -803,10 +806,11 @@ class T_subtensor(unittest.TestCase): ...@@ -803,10 +806,11 @@ class T_subtensor(unittest.TestCase):
oldlevel = _logger.getEffectiveLevel() oldlevel = _logger.getEffectiveLevel()
_logger.setLevel(logging.CRITICAL) _logger.setLevel(logging.CRITICAL)
try: try:
tval = eval_outputs([t]) try:
assert 0 tval = eval_outputs([t])
except IndexError, e: assert 0
pass except IndexError, e:
pass
finally: finally:
_logger.setLevel(oldlevel) _logger.setLevel(oldlevel)
def test2_err_bounds1(self): def test2_err_bounds1(self):
...@@ -816,10 +820,11 @@ class T_subtensor(unittest.TestCase): ...@@ -816,10 +820,11 @@ class T_subtensor(unittest.TestCase):
old_stderr = sys.stderr old_stderr = sys.stderr
sys.stderr = StringIO.StringIO() sys.stderr = StringIO.StringIO()
try: try:
tval = eval_outputs([t]) try:
except Exception, e: tval = eval_outputs([t])
if e[0] != 'index out of bounds': except Exception, e:
raise if e[0] != 'index out of bounds':
raise
finally: finally:
sys.stderr = old_stderr sys.stderr = old_stderr
def test2_ok_elem(self): def test2_ok_elem(self):
...@@ -1497,10 +1502,11 @@ class t_dot(unittest.TestCase): ...@@ -1497,10 +1502,11 @@ class t_dot(unittest.TestCase):
oldlevel = _logger.getEffectiveLevel() oldlevel = _logger.getEffectiveLevel()
_logger.setLevel(logging.CRITICAL) _logger.setLevel(logging.CRITICAL)
try: try:
tz = eval_outputs([z]) try:
assert False # should have raised exception tz = eval_outputs([z])
except ValueError, e: assert False # should have raised exception
self.failUnless( except ValueError, e:
self.failUnless(
e[0].split()[1:4] == ['are', 'not', 'aligned'] or # reported by numpy e[0].split()[1:4] == ['are', 'not', 'aligned'] or # reported by numpy
e[0].split()[0:2] == ['Shape', 'mismatch:'], e) # reported by blas return self.fail() e[0].split()[0:2] == ['Shape', 'mismatch:'], e) # reported by blas return self.fail()
finally: finally:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论