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

Chapter 36. Registering New WebDAV Names... > Step 3: Unit-Testing and Configuring...

Step 3: Unit-Testing and Configuring the Adapter

For the unit tests of the adapter, you use doc tests. To do so, you extend the adapter's class doc string so that it looks like this:

01 """Implement IPhoto namespace for IImage.
02
03 Examples:
04
05 >>> from zope.app.file.image import Image
06 >>> image = Image()
07 >>> photo = IPhoto(image)
08
09 >>> photo.height is None
10 True
11 >>> photo.height = 768
12 >>> photo.height
13 768
14 >>> photo.height = u'100'
15 Traceback (most recent call last):
16 ...
17 WrongType: (u'100', (<type 'int'>, <type 'long'>))
18
19 >>> photo.width is None
20 True
21 >>> photo.width = 1024
22 >>> photo.width
23 1024
24
25 >>> photo.equivalent35mm is None
26 True
27 >>> photo.equivalent35mm = u'41 mm'
28 >>> photo.equivalent35mm
29 u'41 mm'
30
31 >>> photo.aperture is None
32 True
33 >>> photo.aperture = u'f/2.8'
34 >>> photo.aperture
35 u'f/2.8'
36
37 >>> photo.exposureTime is None
38 True
39 >>> photo.exposureTime = 0.031
40 >>> photo.exposureTime
41 0.031
42
43 >>> photo.occasion
44 Traceback (most recent call last):
45 ...
46 AttributeError: 'ImagePhotoNamespace' object has no attribute 'occasion'
47 """


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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