123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import time
- SLEEP = 0.5
- # Complex Parts
- class TC1:
- def run(self):
- print("###### In Test 1 ######")
- time.sleep(SLEEP)
- print("Setting up")
- time.sleep(SLEEP)
- print("Running test")
- time.sleep(SLEEP)
- print("Tearing down")
- time.sleep(SLEEP)
- print("Test Finished\n")
- class TC2:
- def run(self):
- print("###### In Test 2 ######")
- time.sleep(SLEEP)
- print("Setting up")
- time.sleep(SLEEP)
- print("Running test")
- time.sleep(SLEEP)
- print("Tearing down")
- time.sleep(SLEEP)
- print("Test Finished\n")
- class TC3:
- def run(self):
- print("###### In Test 3 ######")
- time.sleep(SLEEP)
- print("Setting up")
- time.sleep(SLEEP)
- print("Running test")
- time.sleep(SLEEP)
- print("Tearing down")
- time.sleep(SLEEP)
- print("Test Finished\n")
- # Facade
- class TestRunner:
- def __init__(self):
- self.tc1 = TC1()
- self.tc2 = TC2()
- self.tc3 = TC3()
- self.tests = [i for i in (self.tc1, self.tc2, self.tc3)]
- def runAll(self):
- [i.run() for i in self.tests]
- # Client
- if __name__ == '__main__':
- testrunner = TestRunner()
- testrunner.runAll()
- ### OUTPUT ###
- # ###### In Test 1 ######
- # Setting up
- # Running test
- # Tearing down
- # Test Finished
- #
- # ###### In Test 2 ######
- # Setting up
- # Running test
- # Tearing down
- # Test Finished
- #
- # ###### In Test 3 ######
- # Setting up
- # Running test
- # Tearing down
- # Test Finished
- #
|