facade.py 1.3 KB

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