当前位置: 首页>>代码示例>>Python>>正文


Python tools.assert_is_instance方法代码示例

本文整理汇总了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)) 
开发者ID:zhanghan1990,项目名称:zipline-chinese,代码行数:21,代码来源:serialization_cases.py

示例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)) 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:20,代码来源:children_container_test.py

示例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)) 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:20,代码来源:children_container_test.py

示例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)) 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:19,代码来源:children_container_test.py

示例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'
        ]) 
开发者ID:caleb531,项目名称:automata,代码行数:9,代码来源:test_dfa.py

示例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)') 
开发者ID:caleb531,项目名称:automata,代码行数:11,代码来源:test_dtm.py

示例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)') 
开发者ID:caleb531,项目名称:automata,代码行数:13,代码来源:test_ntm.py

示例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'}
        ]) 
开发者ID:caleb531,项目名称:automata,代码行数:9,代码来源:test_nfa.py

示例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',
         ]) 
开发者ID:sailthru,项目名称:stolos,代码行数:34,代码来源:test_api.py

示例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()) 
开发者ID:sailthru,项目名称:stolos,代码行数:7,代码来源:test_api.py

示例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) 
开发者ID:sailthru,项目名称:stolos,代码行数:9,代码来源:test_json_config.py

示例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) 
开发者ID:sailthru,项目名称:stolos,代码行数:15,代码来源:test_redis_config.py

示例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]) 
开发者ID:sailthru,项目名称:stolos,代码行数:35,代码来源:test_redis_config.py

示例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')) 
开发者ID:escorciav,项目名称:deep-action-proposals,代码行数:9,代码来源:test_datasets.py

示例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']) 
开发者ID:intelie,项目名称:django-oidc-auth,代码行数:12,代码来源:utils.py


注:本文中的nose.tools.assert_is_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。