diff --git a/schema.py b/schema.py index d2376a0..ee8d65f 100644 --- a/schema.py +++ b/schema.py @@ -1,3 +1,5 @@ +import inspect + __version__ = '0.2.0' @@ -159,7 +161,7 @@ def validate(self, data): except BaseException as x: raise SchemaError('%r.validate(%r) raised %r' % (s, data, x), self._error) - if type(s) is type: + if inspect.isclass(s): if isinstance(data, s): return data else: diff --git a/test_schema.py b/test_schema.py index 2a0d55a..74f3550 100644 --- a/test_schema.py +++ b/test_schema.py @@ -333,3 +333,11 @@ def test_issue_9_prioritized_key_comparison_in_dicts(): assert s.validate(data) == data data = {'ID': 10, 'FILE': None} assert s.validate(data) == data + + +def test_old_style_classes(): + # This test should be done with Python 2 + + class Bar: pass + + assert Schema(Bar).validate(Bar())