Explorar o código

Fixed non-determinism when the wrong model and fixed control model is sent

Yentl Van Tendeloo %!s(int64=8) %!d(string=hai) anos
pai
achega
a23b269e9b
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  1. 7 6
      integration/test_powerwindow.py

+ 7 - 6
integration/test_powerwindow.py

@@ -63,11 +63,12 @@ class TestPowerWindow(unittest.TestCase):
 
 
         global called
         global called
         called = 0
         called = 0
+        nr_of_operations = 6
 
 
         def get_function(filename):
         def get_function(filename):
             def func():
             def func():
                 global called
                 global called
-                if called > len(callbacks):
+                if called > nr_of_operations:
                     raise Exception("Seemingly called some operation twice!")
                     raise Exception("Seemingly called some operation twice!")
                 else:
                 else:
                     called += 1
                     called += 1
@@ -153,6 +154,7 @@ class TestPowerWindow(unittest.TestCase):
 
 
         global called
         global called
         called = 0
         called = 0
+        executed = set([])
 
 
         def get_function(filename, fixed=None):
         def get_function(filename, fixed=None):
             def func():
             def func():
@@ -160,12 +162,11 @@ class TestPowerWindow(unittest.TestCase):
                 if called > len(callbacks) * 2:
                 if called > len(callbacks) * 2:
                     raise Exception("Seemingly called some operation twice!")
                     raise Exception("Seemingly called some operation twice!")
                 called += 1
                 called += 1
-                if called > len(callbacks) and fixed is not None:
-                    print("Uploading fixed!")
-                    model_overwrite(None, open(fixed, "r").read())
-                else:
-                    print("Uploading first for %s!" % filename)
+                if filename not in executed or fixed is None:
+                    executed.add(filename)
                     model_overwrite(None, open(filename, "r").read())
                     model_overwrite(None, open(filename, "r").read())
+                else:
+                    model_overwrite(None, open(fixed, "r").read())
             return func
             return func
 
 
         cb_req = get_function("models/requirements_model.mvc")
         cb_req = get_function("models/requirements_model.mvc")