facade.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. '''http://dpip.testingperspective.com/?p=26'''
  2. import time
  3. SLEEP = 0.5
  4. # Complex Parts
  5. class TC1:
  6. def run(self):
  7. print("###### In Test 1 ######")
  8. time.sleep(SLEEP)
  9. print("Setting up")
  10. time.sleep(SLEEP)
  11. print("Running test")
  12. time.sleep(SLEEP)
  13. print("Tearing down")
  14. time.sleep(SLEEP)
  15. print("Test Finished\n")
  16. class TC2:
  17. def run(self):
  18. print("###### In Test 2 ######")
  19. time.sleep(SLEEP)
  20. print("Setting up")
  21. time.sleep(SLEEP)
  22. print("Running test")
  23. time.sleep(SLEEP)
  24. print("Tearing down")
  25. time.sleep(SLEEP)
  26. print("Test Finished\n")
  27. class TC3:
  28. def run(self):
  29. print("###### In Test 3 ######")
  30. time.sleep(SLEEP)
  31. print("Setting up")
  32. time.sleep(SLEEP)
  33. print("Running test")
  34. time.sleep(SLEEP)
  35. print("Tearing down")
  36. time.sleep(SLEEP)
  37. print("Test Finished\n")
  38. # Facade
  39. class TestRunner:
  40. def __init__(self):
  41. self.tc1 = TC1()
  42. self.tc2 = TC2()
  43. self.tc3 = TC3()
  44. self.tests = [i for i in (self.tc1, self.tc2, self.tc3)]
  45. def runAll(self):
  46. [i.run() for i in self.tests]
  47. # Client
  48. if __name__ == '__main__':
  49. testrunner = TestRunner()
  50. testrunner.runAll()