Advertisement
rfmonk

unittest_ex2.py

Sep 9th, 2014
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. #! /usr/bin/env python
  2. """
  3. """
  4. import unittest
  5.  
  6. class FooTest(unittest.TestCase):
  7.     """ Sample test case """
  8.  
  9.     # preparing the test
  10.     def setUp(self):
  11.         """ Setting up for the test """
  12.         print "FooTest:setUp_:begin"
  13.        
  14.         testName = self.shortDescription()
  15.         if (testName == "Test routine A"):
  16.             print "setting up for test A"
  17.            
  18.         elif (testName == "Test routine B"):
  19.             print "setting up for test B"
  20.  
  21.         else:
  22.             print "UNKNOWN TEST ROUTINE"
  23.  
  24.         print "FooTest:setUp_:end"
  25.    
  26.     # ending the test
  27.     def tearDown(self):
  28.         """ Cleaning up after the test """
  29.         print "FooTest:tearDown_:begin"
  30.  
  31.         testName = self.shortDescription()
  32.         if (testName == "Test routine A"):
  33.             print "cleaning up after test A"
  34.  
  35.         elif (testName == "Test routine B"):
  36.             print "cleaning up after test B"
  37.  
  38.         else:
  39.             print "UNKNOWN TEST ROUTINE"
  40.  
  41.         print "FooTest:tearDown_:end"
  42.  
  43.     # test routine A
  44.     def testA(self):
  45.         """ Test routine A """
  46.         print "FooTest:testA"
  47.  
  48.     # test routine B
  49.     def testB(self):
  50.         """ Test routine B """
  51.         print "FooTest:testB"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement