[tor-commits] [ooni-probe/master] Review the changes to runner.py that are relevant to the new API

art at torproject.org art at torproject.org
Sun Oct 21 18:54:18 UTC 2012


commit 15cdecec83315e5d5b175bf7c3d4670ebb71a544
Author: Arturo Filastò <arturo at filasto.net>
Date:   Sat Oct 20 15:14:21 2012 +0000

    Review the changes to runner.py that are relevant to the new API
    * XXX we should focus on the currently API and aim for dropping support for
      legacy tests. That API had some important design flaws and we should not
      encourage the continued use of it.
---
 ooni/reporter.py |    8 +++-----
 ooni/runner.py   |    9 ++-------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/ooni/reporter.py b/ooni/reporter.py
index 5de2ff1..fd64cbe 100644
--- a/ooni/reporter.py
+++ b/ooni/reporter.py
@@ -17,16 +17,14 @@ from twisted.internet import defer
 from ooni.utils import date, log, geodata
 
 try:
-    ## Get rid of the annoying "No route found for 
+    ## Get rid of the annoying "No route found for
     ## IPv6 destination warnings":
     logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
     from scapy.all import packet
 except:
     class FooClass:
-        pass
-    packet = object
-    packet.Packet = FooClass
-
+        Packet = object
+    packet = FooClass
 
 pyunit =  __import__('unittest')
 
diff --git a/ooni/runner.py b/ooni/runner.py
index 59c0c45..7aa8676 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -134,7 +134,7 @@ def makeTestCases(klass, tests, methodPrefix):
 
 def loadTestsAndOptions(classes, config):
     """
-    Takes a list of classes and returns their testcases and options.
+    Takes a list of test classes and returns their testcases and options.
     Legacy tests will be adapted.
     """
 
@@ -164,7 +164,7 @@ def loadTestsAndOptions(classes, config):
                 except AttributeError, ae:
                     options.append([])
                     log.err(ae)
-        elif not isinstance(klass, _old_klass_type):
+        else:
             tests = reflect.prefixedMethodNames(klass, methodPrefix)
             if tests:
                 cases = makeTestCases(klass, tests, methodPrefix)
@@ -176,11 +176,6 @@ def loadTestsAndOptions(classes, config):
             except AttributeError, ae:
                 options.append([])
                 log.err(ae)
-        else:
-            try:
-                raise RuntimeError, "Class is some strange type!"
-            except RuntimeError, re:
-                log.err(re)
 
     return testCases, options
 



More information about the tor-commits mailing list