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

Chapter 17. Changing Size Information > Step 2: Writing and Running Unit Tests

Step 2: Writing and Running Unit Tests

Now you need to write some doc tests for the adapter. You should add the following tests in the doc string of the sizeForSorting() method:

01 Create the adapter first.
02 
03 >>> size = MessageSized(Message())
04
05 Here are some examples of the expected output.
06
07 >>> size.sizeForSorting()
08 ('item', 0)
09 >>> size._message['msg1'] = Message()
10 >>> size.sizeForSorting()
11 ('item', 1)
12 >>> size._message['att1'] = object()
13 >>> size.sizeForSorting()
14 ('item', 2)


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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