92: Added ProxyTarget.name property; added corresponding unit tests

This commit is contained in:
Jason Gerard DeRose 2008-08-08 23:26:17 +00:00
parent e3811f3f45
commit 45201e31c1
2 changed files with 21 additions and 3 deletions

View File

@ -76,6 +76,13 @@ class ReadOnly(object):
class ProxyTarget(ReadOnly): class ProxyTarget(ReadOnly):
__public__ = frozenset() __public__ = frozenset()
def __get_name(self):
"""
Convenience property to return the class name.
"""
return self.__class__.__name__
name = property(__get_name)
@classmethod @classmethod
def implements(cls, arg): def implements(cls, arg):
assert type(cls.__public__) is frozenset assert type(cls.__public__) is frozenset

View File

@ -55,7 +55,7 @@ def test_valid_identifier():
class test_ReadOnly(ClassChecker): class test_ReadOnly(ClassChecker):
""" """
Test the plugable.ReadOnly class Test the `ReadOnly` class
""" """
_cls = plugable.ReadOnly _cls = plugable.ReadOnly
@ -103,17 +103,28 @@ class test_ReadOnly(ClassChecker):
class test_ProxyTarget(ClassChecker): class test_ProxyTarget(ClassChecker):
""" """
Test the plugable.ProxyTarget class. Test the `ProxyTarget` class.
""" """
_cls = plugable.ProxyTarget _cls = plugable.ProxyTarget
def test_class(self): def test_class(self):
assert self.cls.__bases__ == (plugable.ReadOnly,) assert self.cls.__bases__ == (plugable.ReadOnly,)
assert type(self.cls.name) is property
assert self.cls.implements(frozenset()) assert self.cls.implements(frozenset())
def test_name(self):
"""
Test the `name` property.
"""
assert read_only(self.cls(), 'name') == 'ProxyTarget'
class some_subclass(self.cls):
pass
assert read_only(some_subclass(), 'name') == 'some_subclass'
def test_implements(self): def test_implements(self):
""" """
Test the implements() classmethod Test the `implements` classmethod.
""" """
class example(self.cls): class example(self.cls):
__public__ = frozenset(( __public__ = frozenset((