From 87cad5078a3c9ef7a978c85905309ee7d3ec194d Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 14 Aug 2008 17:29:13 +0000 Subject: 160: DictProxy now checks type of d in __init__(); updated unit tests --- ipalib/plugable.py | 1 + ipalib/tests/test_plugable.py | 2 ++ 2 files changed, 3 insertions(+) (limited to 'ipalib') diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 66cb18fe5..ffef8d643 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -484,6 +484,7 @@ class DictProxy(ReadOnly): """ :param d: The ``dict`` instance to proxy. """ + assert type(d) is dict, '`d` must be %r, got %r' % (dict, type(d)) self.__d = d self.__lock__() assert self.__islocked__() diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index 5c907dc7a..2854ee6a6 100644 --- a/ipalib/tests/test_plugable.py +++ b/ipalib/tests/test_plugable.py @@ -461,6 +461,8 @@ class test_DictProxy(ClassChecker): def test_class(self): assert self.cls.__bases__ == (plugable.ReadOnly,) + for non_dict in ('hello', 69, object): + raises(AssertionError, self.cls, non_dict) def test_DictProxy(self): cnt = 10 -- cgit