From 3495c67d57868a02bafe6f1935d4846cd5615bf5 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Sat, 9 Aug 2008 01:46:12 +0000 Subject: 94: Renamed Proxy._clone() method to Proxy.__clone__(); updated unit tests --- ipalib/tests/test_plugable.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'ipalib/tests/test_plugable.py') diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index faf2fd92..605debe5 100644 --- a/ipalib/tests/test_plugable.py +++ b/ipalib/tests/test_plugable.py @@ -174,12 +174,12 @@ class test_ProxyTarget(ClassChecker): class test_Proxy(ClassChecker): """ - Test the `Proxy` class. + Tests the `Proxy` class. """ _cls = plugable.Proxy def test_class(self): - assert self.cls.__bases__ == (plugable.ReadOnly,) + assert self.cls.__bases__ == (plugable.ReadOnly,) def test_proxy(self): # Setup: @@ -242,19 +242,9 @@ class test_Proxy(ClassChecker): p = self.cls(base, i, 'attr_name') assert read_only(p, 'name') == 'add' - # Test _clone(): - i = plugin() - p = self.cls(base, i) - assert read_only(p, 'name') == 'user_add' - c = p._clone('attr_name') - assert isinstance(c, self.cls) - assert read_only(c, 'name') == 'add' - assert c is not p - assert c('whoever') == p('whoever') - def test_implements(self): """ - Test the `implements` method. + Tests the `implements` method. """ class base(object): __public__ = frozenset() @@ -276,6 +266,23 @@ class test_Proxy(ClassChecker): p = self.cls(base, o) assert p.implements(3) == 10 + def test_clone(self): + """ + Tests the `__clone__` method. + """ + class base(object): + __public__ = frozenset() + class sub(base): + name = 'some_name' + label = 'another_name' + + p = self.cls(base, sub()) + assert read_only(p, 'name') == 'some_name' + c = p.__clone__('label') + assert isinstance(c, self.cls) + assert c is not p + assert read_only(c, 'name') == 'another_name' + def test_Plugin(): cls = plugable.Plugin -- cgit