本文整理汇总了Python中nose.tools.assert_is_instance方法的典型用法代码示例。如果您正苦于以下问题:Python tools.assert_is_instance方法的具体用法?Python tools.assert_is_instance怎么用?Python tools.assert_is_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.tools
的用法示例。
在下文中一共展示了tools.assert_is_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_dict_equal
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def assert_dict_equal(d1, d2):
# check keys
nt.assert_is_instance(d1, dict)
nt.assert_is_instance(d2, dict)
nt.assert_set_equal(set(d1.keys()), set(d2.keys()))
for k in d1:
v1 = d1[k]
v2 = d2[k]
asserter = nt.assert_equal
if isinstance(v1, pd.DataFrame):
asserter = tm.assert_frame_equal
if isinstance(v1, pd.Series):
asserter = tm.assert_series_equal
try:
asserter(v1, v2)
except AssertionError:
raise AssertionError('{k} is not equal'.format(k=k))
示例2: test_list_children_container
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_list_children_container():
# test to_data
cc = core.ListChildrenContainer([])
nt.assert_equal([], cc.to_data())
# test children_container_to_data
as_data = core.children_container_to_data(cc)
nt.assert_equal(dict(
children_container_key="list",
children_container_data=[],
),
as_data)
# test back and forth
cc2 = core.children_container_from_data(as_data)
nt.assert_is_instance(cc2, core.ListChildrenContainer)
nt.assert_equal(as_data,
core.children_container_to_data(cc2))
示例3: test_dict_children_container
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_dict_children_container():
# test to_data
cc = core.DictChildrenContainer({})
nt.assert_equal({}, cc.to_data())
# test children_container_to_data
as_data = core.children_container_to_data(cc)
nt.assert_equal(dict(
children_container_key="dict",
children_container_data={},
),
as_data)
# test back and forth
cc2 = core.children_container_from_data(as_data)
nt.assert_is_instance(cc2, core.DictChildrenContainer)
nt.assert_equal(as_data,
core.children_container_to_data(cc2))
示例4: test_nodes_and_edges_children_container
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_nodes_and_edges_children_container():
# test to_data
cc = core.NodesAndEdgesContainer([[], []])
nt.assert_equal({"nodes": [], "edges": []}, cc.to_data())
# test children_container_to_data
as_data = core.children_container_to_data(cc)
nt.assert_equal(dict(
children_container_key="nodes_and_edges",
children_container_data={"nodes": [], "edges": []}),
as_data)
# test back and forth
cc2 = core.children_container_from_data(as_data)
nt.assert_is_instance(cc2, core.NodesAndEdgesContainer)
nt.assert_equal(as_data,
core.children_container_to_data(cc2))
示例5: test_read_input_step
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_read_input_step(self):
"""Should return validation generator if step flag is supplied."""
validation_generator = self.dfa.read_input_stepwise('0111')
nose.assert_is_instance(validation_generator, types.GeneratorType)
nose.assert_equal(list(validation_generator), [
'q0', 'q0', 'q1', 'q2', 'q1'
])
示例6: test_read_input_step
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_read_input_step(self):
"""Should return validation generator if step flag is supplied."""
validation_generator = self.dtm1.read_input_stepwise('00001111')
nose.assert_is_instance(validation_generator, types.GeneratorType)
configs = list(validation_generator)
nose.assert_equal(configs[0][0], 'q0')
nose.assert_equal(str(configs[0][1]), 'TMTape(\'00001111\', 0)')
nose.assert_equal(configs[-1][0], 'q4')
nose.assert_equal(str(configs[-1][1]), 'TMTape(\'xxxxyyyy..\', 9)')
示例7: test_read_input_step
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_read_input_step(self):
"""Should return validation generator if step flag is supplied."""
validation_generator = self.ntm1.read_input_stepwise('00120001111')
nose.assert_is_instance(validation_generator, types.GeneratorType)
configs = list(validation_generator)
first_config = configs[0].pop()
nose.assert_equal(first_config[0], 'q0')
nose.assert_equal(str(first_config[1]), 'TMTape(\'00120001111\', 0)')
last_config = configs[-1].pop()
nose.assert_equal(last_config[0], 'q3')
nose.assert_equal(str(last_config[1]), 'TMTape(\'00120001111.\', 11)')
示例8: test_read_input_step
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_read_input_step(self):
"""Should return validation generator if step flag is supplied."""
validation_generator = self.nfa.read_input_stepwise('aba')
nose.assert_is_instance(validation_generator, types.GeneratorType)
nose.assert_equal(list(validation_generator), [
{'q0'}, {'q1', 'q2'}, {'q0'}, {'q1', 'q2'}
])
示例9: test_get_tasks_config
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_get_tasks_config():
tc = api.get_tasks_config()
nt.assert_is_instance(tc, TasksConfigBaseMapping)
nt.assert_count_equal(
tc,
['test_stolos/test_get_tasks_config/depends_on2',
'test_stolos/test_get_tasks_config/custom_job_id1',
'test_stolos/test_get_tasks_config/app2',
'test_stolos/test_get_tasks_config/topological_sort1',
'test_stolos/test_get_tasks_config/fanout1',
'test_stolos/test_get_tasks_config/depends_on1',
'test_stolos/test_get_tasks_config/bash2',
'test_stolos/test_get_tasks_config/app3',
'test_stolos/test_get_tasks_config/app1',
'test_stolos/test_get_tasks_config/bash1',
'test_stolos/test_get_tasks_config/app4',
'test_stolos/test_get_tasks_config/valid1',
'test_stolos/test_get_tasks_config/valid2',
'test_stolos/test_get_tasks_config/valid3',
'test_stolos/test_get_tasks_config/valid3b',
'test_stolos/test_get_tasks_config/valid4',
'test_stolos/test_get_tasks_config/all_test1',
'test_stolos/test_get_tasks_config/all_test2',
'test_stolos/test_get_tasks_config/all_test3',
'test_stolos/test_get_tasks_config/all_test4',
'test_stolos/test_get_tasks_config/all_test4b',
'test_stolos/test_get_tasks_config/all_test5',
'test_stolos/test_get_tasks_config/autofill1',
'test_stolos/test_get_tasks_config/autofill2',
'test_stolos/test_get_tasks_config/autofill3',
'test_stolos/test_get_tasks_config/autofill_getparents',
])
示例10: test_build_dag
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_build_dag():
dag = api.build_dag()
nt.assert_is_instance(dag, MultiDiGraph)
tc = api.get_tasks_config()
nt.assert_count_equal(tc.keys(), dag.node.keys())
示例11: test_get_item
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_get_item(td, raw):
nt.assert_is_instance(td, JSONMapping)
nt.assert_equal(td['a'], 1)
nt.assert_equal(td['b'], JSONSequence(raw['b']))
nt.assert_equal(td['b'][0], 1)
nt.assert_equal(td['c'], JSONMapping(raw['c']))
nt.assert_equal(td['c']['bb'][-1], 3)
示例12: test_get_item
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_get_item(app1, td):
with nt.assert_raises(KeyError):
td['appNotExist']
nt.assert_is_instance(td, RedisMapping)
nt.assert_is_instance(td[app1], JSONMapping)
nt.assert_is_instance(td[app1], JSONMapping)
# are returned values of the correct type?
nt.assert_equal(len(list(td[app1].keys())), 3)
nt.assert_true(all(x in [3, 2, 'key1'] for x in td[app1].keys()))
nt.assert_is_instance(
td[app1][3], JSONSequence)
nt.assert_equal(td[app1]['key1'], 1)
nt.assert_equal(len(td[app1]), 3)
示例13: test_set_config
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_set_config(app1, cli, td):
dct = {
'1': '1',
2: 2,
1.1: 1.1,
'a': 1,
3: ['1', 2],
4: {'a': 1, '1': '1', 2: 2}}
# verify set_config does not delete old keys
nt.assert_in('key1', td[app1])
nt.assert_equal(1, td[app1]['key1'])
td = RedisMapping() # reset's RedisMapping's cache, from prev line
set_config(app1, dct, cli=cli)
nt.assert_in('key1', td[app1])
nt.assert_equal(1, td[app1]['key1'])
# verify set_config adds new keys
nt.assert_equal(
len(list(td[app1].keys())), len(list(dct.keys()) + ['key1']))
nt.assert_true(all(
x in (list(dct.keys()) + ['key1']) for x in td[app1].keys()))
nt.assert_equal('1', td[app1]['1'])
nt.assert_equal(2, td[app1][2])
nt.assert_equal(1.1, td[app1][1.1])
nt.assert_equal(1, td[app1]['a'])
nt.assert_is_instance(
td[app1][3], JSONSequence)
nt.assert_is_instance(
td[app1][4], JSONMapping)
nt.assert_list_equal(list(td[app1][3]), dct[3])
nt.assert_dict_equal(dict(td[app1][4]), dct[4])
示例14: test_Dataset
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def test_Dataset():
for i in ['thumos14', 'activitynet']:
ds = Dataset(i)
nt.assert_is_instance(ds.wrapped_dataset, DatasetBase)
# Assert main methods
nt.assert_true(hasattr(ds.wrapped_dataset, 'segments_info'))
nt.assert_true(hasattr(ds.wrapped_dataset, 'video_info'))
示例15: assert_provider_valid
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_is_instance [as 别名]
def assert_provider_valid(self, provider, credentials=None):
if not credentials:
credentials = self.configs
tools.assert_is_instance(provider, OpenIDProvider)
tools.assert_equal(provider.issuer, credentials['issuer'])
tools.assert_equal(provider.authorization_endpoint, credentials['authorization_endpoint'])
tools.assert_equal(provider.token_endpoint, credentials['token_endpoint'])
tools.assert_equal(provider.userinfo_endpoint, credentials['userinfo_endpoint'])
tools.assert_equal(provider.jwks_uri, credentials['jwks_uri'])