ソースを参照

Removed redundant parentheses.

Jeroen 12 年 前
コミット
327e51c9c3
1 ファイル変更83 行追加83 行削除
  1. 83 83
      mediator.py

+ 83 - 83
mediator.py

@@ -1,117 +1,117 @@
 """http://dpip.testingperspective.com/?p=28"""
 """http://dpip.testingperspective.com/?p=28"""
 
 
-import time 
+import time
 
 
 
 
 class TC:
 class TC:
-    def __init__(self):                         
-        self._tm = tm                         
-        self._bProblem = 0             
-
-    def setup(self):                         
-        print("Setting up the Test")                         
-        time.sleep(1)                         
-        self._tm.prepareReporting()   
-
-    def execute(self):                         
-        if not self._bProblem:                                      
-            print("Executing the test")                                      
-            time.sleep(1)                         
-        else:                                      
-            print("Problem in setup. Test not executed.")             
-
-    def tearDown(self):                         
-        if not self._bProblem:                                      
-            print("Tearing down")                                      
-            time.sleep(1)                                      
-            self._tm.publishReport()                         
-        else:                                      
-            print("Test not executed. No tear down required.")             
+    def __init__(self):
+        self._tm = tm
+        self._bProblem = 0
+
+    def setup(self):
+        print("Setting up the Test")
+        time.sleep(1)
+        self._tm.prepareReporting()
+
+    def execute(self):
+        if not self._bProblem:
+            print("Executing the test")
+            time.sleep(1)
+        else:
+            print("Problem in setup. Test not executed.")
+
+    def tearDown(self):
+        if not self._bProblem:
+            print("Tearing down")
+            time.sleep(1)
+            self._tm.publishReport()
+        else:
+            print("Test not executed. No tear down required.")
 
 
     def setTM(self, TM):
     def setTM(self, TM):
-        self._tm = tm             
+        self._tm = tm
 
 
-    def setProblem(self, value):                         
-        self._bProblem = value 
+    def setProblem(self, value):
+        self._bProblem = value
 
 
 
 
 class Reporter:
 class Reporter:
-    def __init__(self):                         
-        self._tm = None             
+    def __init__(self):
+        self._tm = None
 
 
-    def prepare(self):                         
-        print("Reporter Class is preparing to report the results")                         
-        time.sleep(1)             
+    def prepare(self):
+        print("Reporter Class is preparing to report the results")
+        time.sleep(1)
 
 
-    def report(self):                         
-        print("Reporting the results of Test")                         
-        time.sleep(1)             
+    def report(self):
+        print("Reporting the results of Test")
+        time.sleep(1)
 
 
     def setTM(self, TM):
     def setTM(self, TM):
-        self._tm = tm 
+        self._tm = tm
 
 
 
 
 class DB:
 class DB:
-    def __init__(self):                         
-        self._tm = None             
-
-    def insert(self):                         
-        print("Inserting the execution begin status in the Database")                         
-        time.sleep(1)                         
-        #Following code is to simulate a communication from DB to TC                         
-        import random                         
+    def __init__(self):
+        self._tm = None
+
+    def insert(self):
+        print("Inserting the execution begin status in the Database")
+        time.sleep(1)
+        #Following code is to simulate a communication from DB to TC
+        import random
         if random.randrange(1, 4) == 3:
         if random.randrange(1, 4) == 3:
-            return -1             
+            return -1
 
 
-    def update(self):                         
-        print("Updating the test results in Database")                         
-        time.sleep(1)             
+    def update(self):
+        print("Updating the test results in Database")
+        time.sleep(1)
 
 
     def setTM(self, TM):
     def setTM(self, TM):
-        self._tm = tm 
+        self._tm = tm
 
 
 
 
 class TestManager:
 class TestManager:
-    def __init__(self):                         
-        self._reporter = None                         
-        self._db = None                         
-        self._tc = None             
+    def __init__(self):
+        self._reporter = None
+        self._db = None
+        self._tc = None
 
 
-    def prepareReporting(self):                         
-        rvalue = self._db.insert()                         
-        if rvalue == -1:                                      
-            self._tc.setProblem(1)                                      
-            self._reporter.prepare()             
+    def prepareReporting(self):
+        rvalue = self._db.insert()
+        if rvalue == -1:
+            self._tc.setProblem(1)
+            self._reporter.prepare()
 
 
-    def setReporter(self, reporter):                         
-        self._reporter = reporter             
+    def setReporter(self, reporter):
+        self._reporter = reporter
 
 
-    def setDB(self, db):                         
-        self._db = db             
+    def setDB(self, db):
+        self._db = db
 
 
-    def publishReport(self):                         
-        self._db.update()                         
-        rvalue = self._reporter.report()             
+    def publishReport(self):
+        self._db.update()
+        rvalue = self._reporter.report()
 
 
     def setTC(self, tc):
     def setTC(self, tc):
-        self._tc = tc 
-
-
-if __name__ == '__main__':             
-    reporter = Reporter()             
-    db = DB()             
-    tm = TestManager()             
-    tm.setReporter(reporter)             
-    tm.setDB(db)             
-    reporter.setTM(tm)             
-    db.setTM(tm)             
-    # For simplification we are looping on the same test.             
+        self._tc = tc
+
+
+if __name__ == '__main__':
+    reporter = Reporter()
+    db = DB()
+    tm = TestManager()
+    tm.setReporter(reporter)
+    tm.setDB(db)
+    reporter.setTM(tm)
+    db.setTM(tm)
+    # For simplification we are looping on the same test.
     # Practically, it could be about various unique test classes and their
     # Practically, it could be about various unique test classes and their
     # objects
     # objects
-    while (True):                         
-        tc = TC()                         
-        tc.setTM(tm)                         
-        tm.setTC(tc)                         
-        tc.setup()                         
-        tc.execute()                         
+    while True:
+        tc = TC()
+        tc.setTM(tm)
+        tm.setTC(tc)
+        tc.setup()
+        tc.execute()
         tc.tearDown()
         tc.tearDown()