From d8dc368dd016107c777b8a00559d43af772177a7 Mon Sep 17 00:00:00 2001 From: Rogdham Date: Thu, 18 Apr 2013 17:57:17 +0100 Subject: [PATCH] Make empty Or raise SchemaError. Fixes #13. --- schema.py | 2 +- test_schema.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/schema.py b/schema.py index 2c596b1..5a3ed3b 100644 --- a/schema.py +++ b/schema.py @@ -47,7 +47,7 @@ def validate(self, data): class Or(And): def validate(self, data): - x = None + x = SchemaError([], []) for s in [Schema(s, error=self._error) for s in self._args]: try: return s.validate(data) diff --git a/test_schema.py b/test_schema.py index b34b5d0..724f9aa 100644 --- a/test_schema.py +++ b/test_schema.py @@ -66,6 +66,8 @@ def test_or(): assert Or(int, dict).validate(5) == 5 assert Or(int, dict).validate({}) == {} with SE: Or(int, dict).validate('hai') + assert Or(int).validate(4) + with SE: Or().validate(2) def test_validate_list():