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

Chapter 40. Writing Basic Unit Tests > Implementing the Sample Class

Implementing the Sample Class

Before you can write tests, you have to write some code that you can test. In this case, you will implement a simple class called Sample with public attributes title and description that are accessed via getDescription() and mutated using setDescription(). Further, the description must be either a regular or Unicode string.

Because this code does not depend on Zope, you should open a file named test_sample.py anywhere and add the following class to it:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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