Переглянути джерело

Speed up the mediator example and run it thrice

John Tyree 11 роки тому
батько
коміт
85004d9523
1 змінених файлів з 8 додано та 9 видалено
  1. 8 9
      mediator.py

+ 8 - 9
mediator.py

@@ -14,20 +14,20 @@ class TC:
 
     def setup(self):
         print("Setting up the Test")
-        time.sleep(1)
+        time.sleep(0.1)
         self._tm.prepareReporting()
 
     def execute(self):
         if not self._bProblem:
             print("Executing the test")
-            time.sleep(1)
+            time.sleep(0.1)
         else:
             print("Problem in setup. Test not executed.")
 
     def tearDown(self):
         if not self._bProblem:
             print("Tearing down")
-            time.sleep(1)
+            time.sleep(0.1)
             self._tm.publishReport()
         else:
             print("Test not executed. No tear down required.")
@@ -45,11 +45,11 @@ class Reporter:
 
     def prepare(self):
         print("Reporter Class is preparing to report the results")
-        time.sleep(1)
+        time.sleep(0.1)
 
     def report(self):
         print("Reporting the results of Test")
-        time.sleep(1)
+        time.sleep(0.1)
 
     def setTM(self, tm):
         self._tm = tm
@@ -61,15 +61,14 @@ class DB:
 
     def insert(self):
         print("Inserting the execution begin status in the Database")
-        time.sleep(1)
+        time.sleep(0.1)
         #Following code is to simulate a communication from DB to TC
-        import random
         if random.randrange(1, 4) == 3:
             return -1
 
     def update(self):
         print("Updating the test results in Database")
-        time.sleep(1)
+        time.sleep(0.1)
 
     def setTM(self, tm):
         self._tm = tm
@@ -112,7 +111,7 @@ if __name__ == '__main__':
     # For simplification we are looping on the same test.
     # Practically, it could be about various unique test classes and their
     # objects
-    while True:
+    for i in range(3):
         tc = TC()
         tc.setTM(tm)
         tm.setTC(tc)