Advertisement
alexarnon

Untitled

Sep 9th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. """
  2. Example of test subclassing.
  3. """
  4.  
  5. import unittest
  6.  
  7.  
  8. class CommonStuff (unittest.TestCase):
  9.  
  10.     def setUp(self):
  11.         print "CommonStuff: setup (class={} self={})".format(self.__class__.__name__, id(self))
  12.  
  13.     def tearDown(self):
  14.         print "CommonStuff: tearDown (class={} self={})".format(self.__class__.__name__, id(self))
  15.  
  16.  
  17. class TestOne (CommonStuff):
  18.  
  19.     def setUp(self):
  20.         super(TestOne, self).setUp()
  21.         print "TestOne: setup (class={} self={})".format(self.__class__.__name__, id(self))
  22.  
  23.     def tearDown(self):
  24.         print "TestOne: tearDown (class={} self={})".format(self.__class__.__name__, id(self))
  25.         super(TestOne, self).tearDown()
  26.  
  27.     def test_1(self):
  28.         print "TestOne: test_1"
  29.  
  30.     def test_2(self):
  31.         print "TestOne: test_2"
  32.  
  33.  
  34. class TestTwo (CommonStuff):
  35.  
  36.     def test_3(self):
  37.         print "TestTwo: test_3"
  38.  
  39.     def test_4(self):
  40.         print "TestTwo: test_4"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement