Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. from nose import with_setup
  2.  
  3. def setup_module(module):
  4. print ("") # this is to get a newline after the dots
  5. print ("Start testing module: " + str(module))
  6.  
  7. def teardown_module(module):
  8. print ("") # this is to get a newline after the dots
  9. print ("Done testing module: " + str(module))
  10.  
  11. def my_setup_function():
  12. print ("my_setup_function")
  13.  
  14. def my_teardown_function():
  15. print ("my_teardown_function")
  16.  
  17. @with_setup(my_setup_function, my_teardown_function)
  18. def test_numbers_3_4():
  19. print 'test_numbers_3_4 <============================ actual test code'
  20. assert 3*4 == 12
  21.  
  22. @with_setup(my_setup_function, my_teardown_function)
  23. def test_strings_a_3():
  24. print 'test_strings_a_3 <============================ actual test code'
  25. assert 'a'*3 == 'aaa'
  26.  
  27.  
  28. class TestUM:
  29.  
  30. def setup(self):
  31. print ("TestUM:setup() before each test method")
  32.  
  33. def teardown(self):
  34. print ("TestUM:teardown() after each test method")
  35.  
  36. @classmethod
  37. def setup_class(cls):
  38. print ("Start testing class: " + str(cls))
  39.  
  40. @classmethod
  41. def teardown_class(cls):
  42. print ("Done testing class: " + str(cls))
  43.  
  44. def test_numbers_5_6(self):
  45. print 'test_numbers_5_6() <============================ actual test code'
  46. assert 5*6 == 30
  47.  
  48. def test_strings_b_2(self):
  49. print 'test_strings_b_2() <============================ actual test code'
  50. assert 'b'*2 == 'bb'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement