提交 12ea5c0b authored 作者: Frederic Bastien's avatar Frederic Bastien

In a test, test that we generate an error only when one is needed and test the…

In a test, test that we generate an error only when one is needed and test the type of the error generated.
上级 09507fed
...@@ -34,16 +34,19 @@ def test_may_share_memory(): ...@@ -34,16 +34,19 @@ def test_may_share_memory():
assert may_share_memory(a_,b_,False)==rep assert may_share_memory(a_,b_,False)==rep
assert may_share_memory(b_,a_,False)==rep assert may_share_memory(b_,a_,False)==rep
#test that it raise error when needed.
for a_,b_,rep in [(a,(0,),False),(a,1,False),(a,None,False),]:
if rep == False: if rep == False:
try: try:
may_share_memory(a_,b_) may_share_memory(a_,b_)
raise Exception("An error was expected") raise Exception("An error was expected")
except: except TypeError:
pass pass
try: try:
may_share_memory(b_,a_) may_share_memory(b_,a_)
raise Exception("An error was expected") raise Exception("An error was expected")
except: except TypeError:
pass pass
if scipy_imported: if scipy_imported:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论