提交 fdc95437 authored 作者: nouiz's avatar nouiz

Merge pull request #413 from lamblin/fix_test_op_no_input

In filter, raise TypeError or ValueError.
...@@ -39,7 +39,10 @@ class MyType(Type): ...@@ -39,7 +39,10 @@ class MyType(Type):
def filter(self, x, strict=False, allow_downcast=None): def filter(self, x, strict=False, allow_downcast=None):
# Dummy filter: we want this type to represent strings that # Dummy filter: we want this type to represent strings that
# start with `self.thingy`. # start with `self.thingy`.
assert isinstance(x, basestring) and x.startswith(self.thingy) if not isinstance(x, basestring):
raise TypeError("Invalid type")
if not x.startswith(self.thingy):
raise ValueError("Invalid value")
return x return x
class MyOp(Op): class MyOp(Op):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论