本文整理匯總了Python中tester.Tester類的典型用法代碼示例。如果您正苦於以下問題:Python Tester類的具體用法?Python Tester怎麽用?Python Tester使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Tester類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
def main(args):
with file('arena.json', 'rb') as json_f:
config = json.load(json_f)
svc_list = config['services']
cns_list = config['consumers']
sts_list = config['suites']
if len(args) < 2:
exit_errmsg(USAGE.format(progname=args[0],
services=usage_format(svc_list),
consumers=usage_format(cns_list),
suites=usage_format(sts_list)))
else:
tst = Tester()
if args[1] == 'test':
svc_name, cns_name = args[2:4]
tst.test_pair(resolve(svc_list, svc_name, 'service'),
resolve(cns_list, cns_name, 'consumer'))
elif args[1] == 'clean':
tst.clean(config[args[2] + 's'][args[3]])
elif args[1] == 'measure':
if len(args) < 3:
suites = sts_list.itervalues()
else:
suites = [resolve(sts_list, args[2], 'suite')]
if len(args) < 4:
repeats = config['measurement']['repeats']
else:
repeats = [int(args[3])]
if len(args) < 5:
runs = config['measurement']['runs']
else:
runs = int(args[4])
measure(suites, repeats, runs, svc_list, cns_list)
else:
exit_errmsg('Invalid command: "{0}"'.format(args[1]))
示例2: main
def main(config):
prepare_dirs_and_logger(config)
save_config(config)
if config.is_train:
from trainer import Trainer
if config.dataset == 'line':
from data_line import BatchManager
elif config.dataset == 'ch':
from data_ch import BatchManager
elif config.dataset == 'kanji':
from data_kanji import BatchManager
elif config.dataset == 'baseball' or\
config.dataset == 'cat':
from data_qdraw import BatchManager
batch_manager = BatchManager(config)
trainer = Trainer(config, batch_manager)
trainer.train()
else:
from tester import Tester
if config.dataset == 'line':
from data_line import BatchManager
elif config.dataset == 'ch':
from data_ch import BatchManager
elif config.dataset == 'kanji':
from data_kanji import BatchManager
elif config.dataset == 'baseball' or\
config.dataset == 'cat':
from data_qdraw import BatchManager
batch_manager = BatchManager(config)
tester = Tester(config, batch_manager)
tester.test()
示例3: cmd_test
def cmd_test(args, auth, cookies):
if args.commonwords is not None:
words = list()
for word in args.commonwords:
word = word.rstrip("\n")
if word:
words.append(word)
args.commonwords.close()
else:
words = []
sensitive_data, vectors = [], []
for sensitive in args.sensitive:
sensitive = sensitive.rstrip("\n")
if sensitive:
sensitive_data.append(sensitive)
args.sensitive.close()
for v in args.vectors:
v = v.rstrip("\n")
if v:
vectors.append(v)
args.vectors.close()
crawler = Site(words, args.blacklist)
crawler.crawl(args.url, auth, cookies)
fuzzer = Tester(crawler, sensitive_data, vectors, args.slow, args.random)
if args.random:
fuzzer.run_random()
else:
fuzzer.run()
示例4: test_two_A_responses
def test_two_A_responses():
qname = "dualstack.mc-12555-1019789594.us-east-1.elb.amazonaws.com."
T = Tester()
T.newtest(testname="py.test")
response = dbdns.query(T, qname, dns.rdatatype.A)
count = 0
for rrset in response.answer:
for rr in rrset:
if rr.rdtype == dns.rdatatype.A:
print("IP address for {} is {}".format(qname, rr.address))
count += 1
assert count >= 2
示例5: test_a_read
def test_a_read():
qname = "google-public-dns-a.google.com."
T = Tester()
T.newtest(testname="py.test")
response = dbdns.query(T, qname, dns.rdatatype.A)
count = 0
for rrset in response.answer:
for rr in rrset:
if rr.rdtype == dns.rdatatype.A:
print("IP addr for {} is {}".format(qname, rr.address))
assert rr.address == "8.8.8.8"
count += 1
assert count > 0
示例6: test_read_tlsa
def test_read_tlsa():
"""Verify that a TLSA record can be read"""
qname = "_443._tcp.good.dane.verisignlabs.com"
T = Tester()
T.newtest(testname="py.test")
response = dbdns.query(T, qname, dns.rdatatype.TLSA)
count = 0
for rrset in response.answer:
for rr in rrset:
if rr.rdtype == dns.rdatatype.TLSA:
print("{}: {} {} {} {}".format(qname, rr.usage, rr.selector, rr.mtype, hexdump(rr.cert)))
count += 1
assert count > 0
示例7: test_dnssec_response_notpresent
def test_dnssec_response_notpresent():
qname = "www.google.com"
T = Tester()
T.newtest(testname="py.test")
response = dbdns.query(T, qname, dns.rdatatype.A)
count = 0
for rrset in response.answer:
for rr in rrset:
if rr.rdtype == dns.rdatatype.A:
dnssec = response.flags & dns.flags.AD
print("IP address for {} is {} DNSSEC: {}".format(qname, rr.address, dnssec))
if dnssec:
count += 1
assert count == 0
示例8: test_cname_read
def test_cname_read():
# This test makes use of the fact that a.nitroba.org is set as a cname to b.nitroba.org
qname = "a.nitroba.org"
T = Tester()
T.newtest(testname="py.test")
response = dbdns.query(T, qname, dns.rdatatype.CNAME)
count = 0
for rset in response.answer:
for rr in rset:
if rr.rdtype == dns.rdatatype.CNAME:
print("cname for a.nitroba.org is {}".format(rr.target))
assert str(rr.target) == "b.nitroba.org."
count += 1
assert count > 0 # no response?
示例9: __init__
def __init__(self, vc, opts):
self.vc = vc
ret,im = vc.read()
self.numGestures = opts.num
self.imHeight,self.imWidth,self.channels = im.shape
self.trainer = Trainer(numGestures=opts.num, numFramesPerGesture=opts.frames, minDescriptorsPerFrame=opts.desc, numWords=opts.words, descType=opts.type, kernel=opts.kernel, numIter=opts.iter, parent=self)
self.tester = Tester(numGestures=opts.num, minDescriptorsPerFrame=opts.desc, numWords=opts.words, descType=opts.type, numPredictions=7, parent=self)
示例10: train_and_test
def train_and_test(image_loader, feature_extractor):
"""
Simple implementation of train and test function
:param image_loader:
:param feature_extractor:
"""
first_class_train_data, first_class_test_data = get_train_and_test_data(params.first_class_params)
second_class_train_data, second_class_test_data = get_train_and_test_data(params.second_class_params)
train_data = list(first_class_train_data) + list(second_class_train_data)
random.shuffle(train_data)
trainer = Trainer(image_loader, feature_extractor)
solve_container = trainer.train(train_data, params.svm_params)
test_data = list(first_class_test_data) + list(second_class_test_data)
tester = Tester(image_loader, solve_container)
return tester.test(test_data)
示例11: measure
def measure(suites, repeats, runs, svc_list, cns_list):
filebase = datetime.now().strftime(FILE_FORMAT)
log = LogFile(filebase)
csv = path.join(getcwd(), filebase + CSV_SUFFIX)
with file(csv, 'w') as f:
f.write('Service;Consumer;Repeats;Suite;Initialization;Invocation')
for suite, repeat, (svc_name, service), (cns_name, consumer), num in product(
suites, repeats, svc_list.iteritems(), cns_list.iteritems(), xrange(runs)):
log.log('{0} using {1} -({2}x)-> {3}, try {4}'.format(
suite['title'], cns_name, repeat, svc_name, num + 1))
tst = Tester()
env = dict(TIMES=str(repeat), CSV_FILE=csv, CSV_PREFIX=';'.join(
(svc_name, cns_name, str(repeat), suite['title'])))
for i in suite['env']:
env[i] = '1'
tst.extend_env(env)
tst.test_pair(service, consumer)
示例12: run_training
def run_training(difficulty, algorithm, output_name):
genotype, haplotype = get_training_file_paths(difficulty)
if algorithm == 'greedy':
g = Greedy(genotype)
t = Tester(g, haplotype, genotype, output_name)
t.run_analysis()
elif algorithm == 'optimal':
o = Optimal(genotype)
t = Tester(o, haplotype, genotype, output_name)
t.run_analysis()
elif algorithm == 'exhaustive':
e = Exhaustive(genotype)
t = Tester(e, haplotype, genotype, output_name)
t.run_analysis()
示例13: run_test
def run_test(difficulty, algorithm, output_name):
genotype = get_test_data_path(difficulty)
if algorithm == 'greedy':
g = Greedy(genotype)
t = Tester(g, None, genotype, output_name)
t.run_analysis()
elif algorithm == 'optimal':
o = Optimal(genotype)
t = Tester(o, None, genotype, output_name)
t.run_analysis()
elif algorithm == 'exhaustive':
e = Exhaustive(genotype)
t = Tester(e, None, genotype, output_name)
t.run_analysis()
示例14: __init__
def __init__(self, solution, case):
self.solution = solution
self.current_mattes = sum([int(x) for x in solution])
self.case = case
self.tester = Tester()
self.valid_solution = False
self.steps = 0
self.METHODS = {
'random_optimizer': self.random_optimizer,
'matte_minimizer': self.matte_minimizer
}
示例15: periodic
def periodic():
from tester import Tester
import argparse
parser = argparse.ArgumentParser(description="database maintenance")
parser.add_argument("--debug", action="store_true")
parser.add_argument("--list", help="List all of the tasks", action="store_true")
args = parser.parse_args()
W = Tester() # get a database connection
c = W.conn.cursor()
if args.list:
c.execute("select workqueueid,testid,created,completed from workqueue")
for line in c:
print(line)
exit(0)
# Run the queue until there is nothing left to run
while True:
c.execute("select workqueueid,testid,task,args from workqueue where isnull(completed)")
count = 0
for (workqueueid, testid, task, task_args_str) in c.fetchall():
count += 1
T = Tester(testid=testid)
task_args = json.loads(task_args_str)
if args.debug or debug:
print("task_args=", task_args)
task_args["state"] = "WORKING"
logging.info("testid={} task={} task_args={}".format(testid, task, task_args))
if eval(task + "(T,task_args)"):
c.execute("update workqueue set completed=now() where workqueueid=%s", (workqueueid,))
W.commit()
if count == 0:
break