本文整理汇总了Python中nose.tools.ok_方法的典型用法代码示例。如果您正苦于以下问题:Python tools.ok_方法的具体用法?Python tools.ok_怎么用?Python tools.ok_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.tools
的用法示例。
在下文中一共展示了tools.ok_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_roots
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def test_roots():
graph = WorkflowGraph()
prod1 = TestProducer()
prod2 = TestProducer()
cons = TestTwoInOneOut()
graph.connect(prod1, 'output', cons, 'input1')
graph.connect(prod2, 'output', cons, 'input2')
roots = set()
non_roots = set()
for node in graph.graph.nodes():
if node.getContainedObject() == cons:
non_roots.add(node)
else:
roots.add(node)
for r in roots:
tools.ok_(p._is_root(r, graph))
for n in non_roots:
tools.eq_(False, p._is_root(n, graph))
示例2: check_main
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def check_main(script):
'''test is if a script can be imported and has a main function.
'''
# The following tries importing, but I ran into problems - thus simply
# do a textual check for now
# path, basename = os.path.split(script)
# pyxfile = os.path.join( path, "_") + basename + "x"
# ignore script with pyximport for now, something does not work
# if not os.path.exists( pyxfile ):
# with warnings.catch_warnings() as w:
# warnings.simplefilter("ignore")
# (file, pathname, description) =
# imp.find_module( basename[:-3], [path,])
# module = imp.load_module( basename, file, pathname, description)
# ok_( "main" in dir(module), "no main function" )
# subsitute gpipe and other subdirectories.
for s in SUBDIRS:
script = re.sub("%s_" % s, "%s/" % s, script)
# check for text match
ok_([x for x in open(script) if x.startswith("def main(")],
"no main function")
示例3: tearDown
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def tearDown(self):
nt.ok_(self.cls_initialized)
module_logger.debug("TestMain class teardown\n")
示例4: testNotEnoughProcesses
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def testNotEnoughProcesses():
prod = TestProducer()
cons1 = TestOneInOneOut()
cons2 = TestOneInOneOut()
graph = WorkflowGraph()
graph.connect(prod, 'output', cons1, 'input')
graph.connect(cons1, 'output', cons2, 'input')
args = argparse.Namespace
args.num = 1
args.simple = False
args.results = True
message = process(graph, inputs={prod: 5}, args=args)
tools.ok_('Not enough processes' in message)
示例5: test_load_graph
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def test_load_graph():
args = argparse.Namespace
args.file = None
args.data = None
args.iter = 1
args.attr = None
args.module = 'dispel4py.examples.graph_testing.pipeline_test'
# reset the node counter
WorkflowNode.node_counter = 0
graph, inputs = p.load_graph_and_inputs(args)
tools.ok_(graph)
tools.eq_({'TestProducer0': 1}, inputs)
示例6: testIterative
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def testIterative():
it = IterativePE()
tools.ok_(it._process(1) is None)
示例7: testConsumer
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def testConsumer():
cons = ConsumerPE()
tools.ok_(cons.process({'input': 1}) is None)
示例8: ok
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def ok(self, expr, msg=None):
"""Shorthand for assert."""
return ok(expr, msg)
示例9: test_cut
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def test_cut():
#generate fake filepath characteristics.
filepath="fake_filepath"
filepath_label="good"
desired_train_pct=.80
N_samples_in_filepath=1000
start_idx=0
stop_idx=999
seeds=[1234, 1235]
filepath_tracker=FilepathTracker(N_samples_in_filepath=N_samples_in_filepath,
filepath_label=filepath_label, start_idx_of_time_series_for_filepath=start_idx, \
stop_idx_of_time_series_for_filepath=stop_idx)
#generate
label_tracker={filepath_label: {"train_pct": desired_train_pct, "data_dirs": [filepath]}}
filepath_trackers={filepath: filepath_tracker} #dict mapping filepaths to filepath_tracker instances.
print("\n \n ... Now testing that we get the same random selection of samples when we set the seed the same ... ")
cut=Cut(label_tracker, filepath_trackers, seed=seeds[0])
use_idxs_seed_1_run_1=cut.use_idxs
withheld_idxs_seed_1_run_1=cut.withheld_idxs
cut=Cut(label_tracker, filepath_trackers, seed=seeds[0])
use_idxs_seed_1_run_2=cut.use_idxs
withheld_idxs_seed_1_run_2=cut.withheld_idxs
nt.ok_(use_idxs_seed_1_run_1==use_idxs_seed_1_run_2)
nt.ok_(withheld_idxs_seed_1_run_1==withheld_idxs_seed_1_run_2)
print("\n \n ... Now testing that we get different random selection of samples when we set the seed differently... ")
cut=Cut(label_tracker, filepath_trackers, seed=seeds[1])
use_idxs_seed_2=cut.use_idxs
withheld_idxs_seed_2=cut.withheld_idxs
nt.ok_(use_idxs_seed_1_run_1!=use_idxs_seed_2)
nt.ok_(withheld_idxs_seed_1_run_1!=withheld_idxs_seed_2)
示例10: tests
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def tests():
for i in range(len(trees)):
def _():
return ok_(newick_parser.parse_string(trees[i]) == results[i])
_.description = "check tree parsing " + str(i)
yield _,
示例11: test_index
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def test_index(self):
"""The front page is working properly"""
response = self.app.get('/')
msg = 'TurboGears 2 is rapid web application development toolkit '\
'designed to make your life easier.'
# You can look for specific strings:
ok_(msg in response)
# You can also access a BeautifulSoup'ed response in your tests
# (First run $ easy_install BeautifulSoup
# and then uncomment the next two lines)
# links = response.html.findAll('a')
# print links
# ok_(links, "Mummy, there are no links here!")
示例12: test_environ
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def test_environ(self):
"""Displaying the wsgi environ works"""
response = self.app.get('/environ.html')
ok_('The keys in the environment are:' in response)
示例13: test_data_json
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def test_data_json(self):
"""The data display demo works with JSON"""
resp = self.app.get('/data.json?a=1&b=2')
ok_(dict(page='data', params={'a':'1', 'b':'2'}) == resp.json, resp.json)
示例14: test_secc_with_manager
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def test_secc_with_manager(self):
"""The manager can access the secure controller"""
# Note how authentication is forged:
environ = {'REMOTE_USER': 'manager'}
resp = self.app.get('/secc', extra_environ=environ, status=200)
ok_('Secure Controller here' in resp.text, resp.text)
示例15: test_structured_logging
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import ok_ [as 别名]
def test_structured_logging(self):
kwargs = {"persist": True}
extra = {"additional": True}
meta = set(["level", "name", "time"])
# Basic structured logger
logger0 = gogo.Gogo("logger0").get_structured_logger("base", **kwargs)
# Structured formatter
formatter = gogo.formatters.structured_formatter
logger1 = gogo.Gogo("logger1", low_formatter=formatter).logger
# JSON formatter
formatter = gogo.formatters.json_formatter
logger2 = gogo.Gogo("logger2", low_formatter=formatter).logger
# Custom logger
logfmt = (
'{"time": "%(asctime)s.%(msecs)d", "name": "%(name)s", "level":'
' "%(levelname)s", "message": "%(message)s", '
'"persist": "%(persist)s", "additional": "%(additional)s"}'
)
fmtr = logging.Formatter(logfmt, datefmt=gogo.formatters.DATEFMT)
logger3 = gogo.Gogo("logger3", low_formatter=fmtr).get_logger(**kwargs)
# Now log some messages
for logger in [logger0, logger1, logger2, logger3]:
logger.debug("message", extra=extra)
lines = sys.stdout.getvalue().strip().split("\n")
results = [loads(l) for l in lines]
# Assert the following loggers provide the log event meta data
nt.assert_is_not_subset(meta, results[0])
nt.assert_is_subset(meta, results[1])
nt.assert_is_subset(meta, results[2])
nt.assert_is_subset(meta, results[3])
# Assert the following loggers provide the `extra` information
nt.assert_in("additional", results[0])
nt.assert_in("additional", results[1])
nt.assert_not_in("additional", results[2])
nt.assert_in("additional", results[3])
# Assert the following loggers provide the `persist` information
nt.assert_in("persist", results[0])
nt.assert_in("persist", results[1])
nt.assert_not_in("persist", results[2])
nt.assert_in("persist", results[3])
# Assert the following loggers provide the `msecs` in the time
nt.assert_false(len(results[0].get("time", [])))
nt.assert_false(len(results[1]["time"][20:]))
nt.ok_(len(results[2]["time"][20:]))
nt.ok_(len(results[3]["time"][20:]))