• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 44. Writing Tests Against Interf... > Implementations of the ISample Inter...

Implementations of the ISample Interface

The first implementation is equivalent to the one you used in Chapter 40, except that now you should call it Sample1 and tell it that it implements the ISample interface:

01 class Sample1(object):
02     """A trivial ISample implementation."""
03
04     implements(ISample)
05
06     # See ISample
07     title = None
08
09     def __init__(self):
10         """Create objects."""
11         self._description = ''
12
13     def setDescription(self, value):
14         """See ISample"""
15         assert isinstance(value, (str, unicode)) 
16         self._description = value
17
18     def getDescription(self):
19         """See ISample"""
20         return self._description


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint