[tor-commits] [ooni-probe/master] UsageOptions with multiple NetTests in a single file
art at torproject.org
art at torproject.org
Sun Aug 24 17:51:33 UTC 2014
commit 288af1412d6138c252d1d1d553077696a57f8bed
Author: kudrom <kudrom at riseup.net>
Date: Wed Aug 20 16:59:35 2014 +0200
UsageOptions with multiple NetTests in a single file
---
ooni/tests/test_nettest.py | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/ooni/tests/test_nettest.py b/ooni/tests/test_nettest.py
index ccbe2dd..f1cc542 100644
--- a/ooni/tests/test_nettest.py
+++ b/ooni/tests/test_nettest.py
@@ -54,6 +54,32 @@ class DummyTestCaseB(NetTestCase):
self.report['foo'] = 'foo'
"""
+double_different_options_net_test_string = """
+from twisted.python import usage
+from ooni.nettest import NetTestCase
+
+class UsageOptionsA(usage.Options):
+ optParameters = [['spam', 's', None, 'ham']]
+
+class UsageOptionsB(usage.Options):
+ optParameters = [['spam', 's', None, 'ham']]
+
+class DummyTestCaseA(NetTestCase):
+
+ usageOptions = UsageOptionsA
+
+ def test_a(self):
+ self.report['bar'] = 'bar'
+
+
+class DummyTestCaseB(NetTestCase):
+
+ usageOptions = UsageOptionsB
+
+ def test_b(self):
+ self.report['foo'] = 'foo'
+"""
+
net_test_root_required = net_test_string + """
requiresRoot = True
"""
@@ -200,6 +226,17 @@ class TestNetTest(unittest.TestCase):
self.verifyMethods(ntl.testCases)
self.verifyClasses(ntl.testCases, set(('DummyTestCaseA', 'DummyTestCaseB')))
+ ntl.checkOptions()
+
+ def test_load_net_test_multiple_different_options(self):
+ ntl = NetTestLoader(dummyArgs)
+ ntl.loadNetTestString(double_different_options_net_test_string)
+
+ self.verifyMethods(ntl.testCases)
+ self.verifyClasses(ntl.testCases, set(('DummyTestCaseA', 'DummyTestCaseB')))
+
+ self.assertRaises(AssertionError, ntl.checkOptions)
+
def test_load_with_option(self):
ntl = NetTestLoader(dummyArgs)
ntl.loadNetTestString(net_test_string)
More information about the tor-commits
mailing list