99: Cleaned up unit tests for plugable.Plugin

This commit is contained in:
Jason Gerard DeRose
2008-08-09 19:09:10 +00:00
parent 5315514f6c
commit e756e12718
2 changed files with 33 additions and 23 deletions

View File

@@ -268,7 +268,7 @@ class Plugin(ProxyTarget):
def __repr__(self):
"""
Returns a fully qualified module_name.class_name() representation that
could be used to contruct this instance.
could be used to construct this Plugin instance.
"""
return '%s.%s()' % (
self.__class__.__module__,

View File

@@ -296,30 +296,40 @@ class test_Proxy(ClassChecker):
assert read_only(c, 'name') == 'another_name'
def test_Plugin():
cls = plugable.Plugin
assert type(cls.name) is property
class test_Plugin(ClassChecker):
"""
Tests the `Plugin` class.
"""
_cls = plugable.Plugin
api = 'the api instance'
p = plugable.Plugin()
assert read_only(p, 'name') == 'Plugin'
assert repr(p) == '%s.Plugin()' % plugable.__name__
assert read_only(p, 'api') is None
raises(AssertionError, p.finalize, None)
p.finalize(api)
assert read_only(p, 'api') is api
raises(AssertionError, p.finalize, api)
def test_class(self):
assert self.cls.__bases__ == (plugable.ProxyTarget,)
assert type(self.cls.api) is property
class some_plugin(plugable.Plugin):
pass
p = some_plugin()
assert read_only(p, 'name') == 'some_plugin'
assert repr(p) == '%s.some_plugin()' % __name__
assert read_only(p, 'api') is None
raises(AssertionError, p.finalize, None)
p.finalize(api)
assert read_only(p, 'api') is api
raises(AssertionError, p.finalize, api)
def test_finalize(self):
"""
Tests the `finalize` method.
"""
api = 'the api instance'
o = self.cls()
assert read_only(o, 'name') == 'Plugin'
assert repr(o) == '%s.Plugin()' % plugable.__name__
assert read_only(o, 'api') is None
raises(AssertionError, o.finalize, None)
o.finalize(api)
assert read_only(o, 'api') is api
raises(AssertionError, o.finalize, api)
class some_plugin(self.cls):
pass
sub = some_plugin()
assert read_only(sub, 'name') == 'some_plugin'
assert repr(sub) == '%s.some_plugin()' % __name__
assert read_only(sub, 'api') is None
raises(AssertionError, sub.finalize, None)
sub.finalize(api)
assert read_only(sub, 'api') is api
raises(AssertionError, sub.finalize, api)
def test_NameSpace():