本文整理汇总了Python中ooni.nettest.NetTestLoader.checkOptions方法的典型用法代码示例。如果您正苦于以下问题:Python NetTestLoader.checkOptions方法的具体用法?Python NetTestLoader.checkOptions怎么用?Python NetTestLoader.checkOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ooni.nettest.NetTestLoader
的用法示例。
在下文中一共展示了NetTestLoader.checkOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_setup_local_options_in_test_cases
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_setup_local_options_in_test_cases(self):
options = {'subargs':dummyArgs, 'test':StringIO(net_test_string)}
ntl = NetTestLoader(options)
ntl.checkOptions()
for test_class, test_method in ntl.testCases:
self.assertEqual(test_class.localOptions, dummyOptions)
示例2: test_singular_input_processor
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_singular_input_processor(self):
"""
Verify that all measurements use the same object as their input processor.
"""
ntl = NetTestLoader(dummyArgs)
ntl.loadNetTestString(generator_id_net_test)
ntl.checkOptions()
director = Director()
self.filename = 'dummy_report.yamloo'
d = director.startNetTest(ntl, self.filename)
@d.addCallback
def complete(result):
with open(self.filename) as report_file:
all_report_entries = yaml.safe_load_all(report_file)
header = all_report_entries.next()
results_case_a = all_report_entries.next()
aa_test, ab_test, ac_test = results_case_a.get('results', [])
results_case_b = all_report_entries.next()
ba_test = results_case_b.get('results', [])[0]
# Within a NetTestCase an inputs object will be consistent
self.assertEqual(aa_test, ab_test, ac_test)
# An inputs object will be different between different NetTestCases
self.assertNotEqual(aa_test, ba_test)
return d
示例3: test_setup_local_options_in_test_cases
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_setup_local_options_in_test_cases(self):
ntl = NetTestLoader(dummyArgs)
ntl.loadNetTestString(net_test_string)
ntl.checkOptions()
for test_class, test_method in ntl.testCases:
self.assertEqual(test_class.localOptions, dummyOptions)
示例4: test_load_net_test_multiple
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_load_net_test_multiple(self):
ntl = NetTestLoader(dummyArgs)
ntl.loadNetTestString(double_net_test_string)
self.verifyMethods(ntl.testCases)
self.verifyClasses(ntl.testCases, set(('DummyTestCaseA', 'DummyTestCaseB')))
ntl.checkOptions()
示例5: test_load_with_invalid_option
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_load_with_invalid_option(self):
options = {'subargs':dummyInvalidArgs,
'test':StringIO(net_test_string)}
try:
ntl = NetTestLoader(options)
ntl.checkOptions()
raise Exception
except UsageError:
pass
示例6: test_generate_measurements_size
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_generate_measurements_size(self):
ntl = NetTestLoader(dummyArgsWithFile)
ntl.loadNetTestString(net_test_string_with_file)
ntl.checkOptions()
net_test = NetTest(ntl, None)
measurements = list(net_test.generateMeasurements())
self.assertEqual(len(measurements), 20)
示例7: test_net_test_inputs
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_net_test_inputs(self):
ntl = NetTestLoader(dummyArgsWithFile)
ntl.loadNetTestString(net_test_string_with_file)
ntl.checkOptions()
nt = NetTest(ntl.getTestCases(), ntl.getTestDetails(), None)
yield nt.initialize()
for test_class, test_methods in nt.testCases:
self.assertEqual(len(list(test_class.inputs)), 10)
示例8: test_load_with_invalid_option
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_load_with_invalid_option(self):
try:
ntl = NetTestLoader(dummyInvalidArgs)
ntl.loadNetTestString(net_test_string)
ntl.checkOptions()
raise Exception
except UsageError:
pass
示例9: test_generate_measurements_size
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_generate_measurements_size(self):
options = {'subargs':dummyArgsWithFile,
'test':StringIO(net_test_string_with_file)}
ntl = NetTestLoader(options)
ntl.checkOptions()
net_test = NetTest(ntl, None)
measurements = list(net_test.generateMeasurements())
self.assertEqual(len(measurements), 20)
示例10: test_generate_measurements_size
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_generate_measurements_size(self):
ntl = NetTestLoader(dummyArgsWithFile)
ntl.loadNetTestString(net_test_string_with_file)
ntl.checkOptions()
net_test = NetTest(ntl.getTestCases(), ntl.getTestDetails(), None)
net_test.initializeInputProcessor()
measurements = list(net_test.generateMeasurements())
self.assertEqual(len(measurements), 20)
示例11: test_start_net_test
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_start_net_test(self):
options = {'test':net_test_string, 'subargs':dummyArgs}
net_test_loader = NetTestLoader(options)
net_test_loader.checkOptions()
d = self.director.startNetTest('', net_test_loader, self.reporters)
@d.addCallback
def done(result):
self.assertEqual(self.director.successfulMeasurements, 20)
return d
示例12: test_net_test_inputs
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_net_test_inputs(self):
ntl = NetTestLoader(dummyArgsWithFile)
ntl.loadNetTestString(net_test_string_with_file)
ntl.checkOptions()
nt = NetTest(ntl.getTestCases(), ntl.getTestDetails(), None)
nt.initializeInputProcessor()
# XXX: if you use the same test_class twice you will have consumed all
# of its inputs!
tested = set([])
for test_instance, test_method, inputs in nt.testInstances:
self.assertEqual(len(list(inputs)), 10)
示例13: test_net_test_inputs
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_net_test_inputs(self):
ntl = NetTestLoader(dummyArgsWithFile)
ntl.loadNetTestString(net_test_string_with_file)
ntl.checkOptions()
# XXX: if you use the same test_class twice you will have consumed all
# of its inputs!
tested = set([])
for test_class, test_method in ntl.testCases:
if test_class not in tested:
tested.update([test_class])
self.assertEqual(len(list(test_class.inputs)), 10)
示例14: _load_ooni
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def _load_ooni(self, task_data):
required_keys = ["test_name"]
for required_key in required_keys:
if required_key not in task_data:
raise MissingTaskDataKey(required_key)
self.ooni['test_name'] = task_data.pop('test_name')
# This raises e.NetTestNotFound, we let it go onto the caller
nettest_path = nettest_to_path(self.ooni['test_name'],
self._arbitrary_paths)
annotations = self._pop_option('annotations', task_data, {})
collector_address = self._pop_option('collector', task_data, None)
try:
self.output_path = self.global_options['reportfile']
except KeyError:
self.output_path = task_data.pop('reportfile', None)
if task_data.get('no-collector', False):
collector_address = None
elif config.reports.upload is False:
collector_address = None
net_test_loader = NetTestLoader(
options_to_args(task_data),
annotations=annotations,
test_file=nettest_path
)
if isinstance(collector_address, dict):
net_test_loader.collector = CollectorClient(
settings=collector_address
)
elif collector_address is not None:
net_test_loader.collector = CollectorClient(
collector_address
)
if (net_test_loader.collector is not None and
net_test_loader.collector.backend_type == "onion"):
self.requires_tor = True
try:
net_test_loader.checkOptions()
if net_test_loader.requiresTor:
self.requires_tor = True
except e.MissingTestHelper:
self.requires_bouncer = True
self.ooni['net_test_loader'] = net_test_loader
示例15: test_nettest_timeout
# 需要导入模块: from ooni.nettest import NetTestLoader [as 别名]
# 或者: from ooni.nettest.NetTestLoader import checkOptions [as 别名]
def test_nettest_timeout(self):
ntl = NetTestLoader(('-u', 'http://localhost:8007/'))
ntl.loadNetTestString(http_net_test)
ntl.checkOptions()
director = Director()
d = director.startNetTest(ntl, [MockReporter()])
@d.addCallback
def complete(result):
assert director.failedMeasurements == 1
return d