[tor-commits] [ooni-probe/master] Do some refactoring of the NetTest class

art at torproject.org art at torproject.org
Mon Nov 12 22:06:08 UTC 2012


commit b33ada65d3b8ddd652b1df8e89e4d14906f06004
Author: Arturo Filastò <art at fuffa.org>
Date:   Mon Nov 12 23:04:21 2012 +0100

    Do some refactoring of the NetTest class
    * Use _setUp for setting up of test templates.
---
 ooni/nettest.py         |    6 ++++++
 ooni/runner.py          |    3 ++-
 ooni/templates/httpt.py |    2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ooni/nettest.py b/ooni/nettest.py
index 8d911eb..fbc5c42 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -103,6 +103,12 @@ class NetTestCase(object):
     requiresRoot = False
 
     localOptions = {}
+    def _setUp(self):
+        """
+        This is the internal setup method to be overwritten by templates.
+        """
+        pass
+
     def setUp(self):
         """
         Place here your logic to be executed when the test is being setup.
diff --git a/ooni/runner.py b/ooni/runner.py
index b27ed63..2b9089a 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -167,7 +167,8 @@ def runTestWithInput(test_class, test_method, test_input, oreporter):
     log.debug("Processing %s" % test_instance.name)
     # use this to keep track of the test runtime
     test_instance._start_time = time.time()
-    # call setup on the test
+    # call setups on the test
+    test_instance._setUp()
     test_instance.setUp()
     test = getattr(test_instance, test_method)
 
diff --git a/ooni/templates/httpt.py b/ooni/templates/httpt.py
index 8360d7d..ee6af90 100644
--- a/ooni/templates/httpt.py
+++ b/ooni/templates/httpt.py
@@ -39,7 +39,7 @@ class HTTPTest(NetTestCase):
     randomizeUA = True
     followRedirects = False
 
-    def setUp(self):
+    def _setUp(self):
         log.debug("Setting up HTTPTest")
         try:
             import OpenSSL





More information about the tor-commits mailing list