[tor-commits] [ooni-probe/master] Refactor naming of nettest related code

art at torproject.org art at torproject.org
Sun Jan 5 23:47:44 UTC 2014


commit cc9fbb70666cf5322956332415dcdbf8cd3592d1
Author: Arturo Filastò <art at fuffa.org>
Date:   Mon Jan 6 00:44:44 2014 +0100

    Refactor naming of nettest related code
---
 ooni/nettest.py |   12 ++++++------
 ooni/tasks.py   |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ooni/nettest.py b/ooni/nettest.py
index a1a46d6..513c11f 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -514,7 +514,7 @@ class NetTest(object):
 
         return report_results
 
-    def makeMeasurement(self, test_class, test_method, test_input=None):
+    def makeMeasurement(self, test_instance, test_method, test_input=None):
         """
         Creates a new instance of :class:ooni.tasks.Measurement and add's it's
         callbacks and errbacks.
@@ -531,7 +531,7 @@ class NetTest(object):
                 NetTestCase
 
         """
-        measurement = Measurement(test_class, test_method, test_input)
+        measurement = Measurement(test_instance, test_method, test_input)
         measurement.netTest = self
 
         if self.director:
@@ -558,10 +558,10 @@ class NetTest(object):
             # load the input processor as late as possible
             for input in test_class.inputs:
                 measurements = []
+                test_instance = test_class()
                 for method in test_methods:
-                    klass = test_class()
                     log.debug("Running %s %s" % (test_class, method))
-                    measurement = self.makeMeasurement(klass, method, input)
+                    measurement = self.makeMeasurement(test_instance, method, input)
                     measurements.append(measurement.done)
                     self.state.taskCreated()
                     yield measurement
@@ -573,11 +573,11 @@ class NetTest(object):
 
                     # Call the postProcessor, which must return a single report
                     # or a deferred
-                    post.addCallback(klass.postProcessor)
+                    post.addCallback(test_instance.postProcessor)
                     def noPostProcessor(failure, report):
                         failure.trap(e.NoPostProcessor)
                         return report
-                    post.addErrback(noPostProcessor, klass.report)
+                    post.addErrback(noPostProcessor, test_instance.report)
                     post.addCallback(self.report.write)
 
                 if self.report and self.director:
diff --git a/ooni/tasks.py b/ooni/tasks.py
index 9e74dd5..3e378e9 100644
--- a/ooni/tasks.py
+++ b/ooni/tasks.py
@@ -91,7 +91,7 @@ class TaskWithTimeout(BaseTask):
         return BaseTask.start(self)
 
 class Measurement(TaskWithTimeout):
-    def __init__(self, test_class, test_method, test_input):
+    def __init__(self, test_instance, test_method, test_input):
         """
         test_class:
             is the class, subclass of NetTestCase, of the test to be run
@@ -106,7 +106,7 @@ class Measurement(TaskWithTimeout):
         net_test:
             a reference to the net_test object such measurement belongs to.
         """
-        self.testInstance = test_class
+        self.testInstance = test_instance
         self.testInstance.input = test_input
         if 'input' not in self.testInstance.report.keys():
             self.testInstance.report = {'input': test_input}





More information about the tor-commits mailing list