14: Added Named.cli property that returns name.replace('_', '-'); Named.doc property now does a strip() to make it more user-friendly; added test_Named unit tests which somehow got dropped, uppdated with new Named properties

This commit is contained in:
Jason Gerard DeRose 2008-07-20 03:48:36 +00:00
parent 370282819d
commit c2df391569
2 changed files with 16 additions and 1 deletions

View File

@ -132,8 +132,12 @@ class Named(object):
return self.__class__.__name__
name = property(__get_name)
def __get_cli(self):
return self.name.replace('_', '-')
cli = property(__get_cli)
def __get_doc(self):
return self.__class__.__doc__
return self.__class__.__doc__.strip()
doc = property(__get_doc)

View File

@ -183,6 +183,17 @@ class test_NameSpace:
assert len(kw) == len(ns) == 3
def test_Named():
class named_class(base.Named):
"""
This class is so introspective!
"""
i = named_class()
assert i.name == 'named_class'
assert i.cli == 'named-class'
assert i.doc == 'This class is so introspective!'
def test_Command():
class user(object):
name = 'user'