• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tools.assert_is函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nose.tools.assert_is函数的典型用法代码示例。如果您正苦于以下问题:Python assert_is函数的具体用法?Python assert_is怎么用?Python assert_is使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_is函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_connect_systems

def test_connect_systems():
    '''check the connect_systems routine'''
    r = sysdiag.System('root')
    s1 = sysdiag.System('s1', parent=r)
    s2 = sysdiag.System('s2') # parent is None 
    # add some ports
    s1.add_port(sysdiag.Port('p1', 'type1'))
    s2.add_port(sysdiag.Port('p2', 'type1'))
    p_other = sysdiag.Port('p_other', 'other type')
    s2.add_port(p_other)

    # failure if no common parents
    with assert_raises(ValueError):
        w1 = sysdiag.connect_systems(s1,s2, 'p1', 'p2')
    r.add_subsystem(s2)
    w1 = sysdiag.connect_systems(s1,s2, 'p1', 'p2')
    assert_equal(len(w1.ports), 2)

    # failure if wrong types of ports:
    assert_equal(w1.is_connect_allowed(p_other, 'sibling'), False)
    with assert_raises(TypeError):
        w = sysdiag.connect_systems(s1,s2, 'p1', 'p_other')

    # double connection: no change is performed
    w2 = sysdiag.connect_systems(s1,s2, 'p1', 'p2')
    assert_is(w2,w1)
    assert_equal(len(w1.ports), 2)
开发者ID:pierre-haessig,项目名称:sysdiag,代码行数:27,代码来源:test_sysdiag.py


示例2: test_annotation

    def test_annotation(self):

        g = dist.jointplot("x", "y", self.data)
        nt.assert_equal(len(g.ax_joint.legend_.get_texts()), 1)

        g = dist.jointplot("x", "y", self.data, stat_func=None)
        nt.assert_is(g.ax_joint.legend_, None)
开发者ID:AlexHecN,项目名称:seaborn,代码行数:7,代码来源:test_distributions.py


示例3: test_lookup_by_type

def test_lookup_by_type():
    f = PlainTextFormatter()
    f.for_type(C, foo_printer)
    nt.assert_is(f.lookup_by_type(C), foo_printer)
    type_str = '%s.%s' % (C.__module__, 'C')
    with nt.assert_raises(KeyError):
        f.lookup_by_type(A)
开发者ID:mattvonrocketstein,项目名称:smash,代码行数:7,代码来源:test_formatters.py


示例4: test_root_graph

 def test_root_graph(self):
     G = self.Graph([(0, 1), (1, 2)])
     assert_is(G, G.root_graph)
     DG = G.to_directed(as_view=True)
     SDG = DG.subgraph([0, 1])
     RSDG = SDG.reverse(copy=False)
     assert_is(G, RSDG.root_graph)
开发者ID:aparamon,项目名称:networkx,代码行数:7,代码来源:test_graph.py


示例5: test_establish_variables_from_series

    def test_establish_variables_from_series(self):

        p = lm._LinearPlotter()
        p.establish_variables(None, x=self.df.x, y=self.df.y)
        pdt.assert_series_equal(p.x, self.df.x)
        pdt.assert_series_equal(p.y, self.df.y)
        nt.assert_is(p.data, None)
开发者ID:kjemmett,项目名称:seaborn,代码行数:7,代码来源:test_linearmodels.py


示例6: import_multiple_aliases_using_same_name_resolve_to_same_node

def import_multiple_aliases_using_same_name_resolve_to_same_node():
    declarations = _create_declarations(["x"])
    first_alias_node = nodes.import_alias("x.y", None)
    second_alias_node = nodes.import_alias("x", None)
    node = nodes.Import([first_alias_node, second_alias_node])
    references = resolve(node, declarations)
    assert_is(references.referenced_declaration(first_alias_node), references.referenced_declaration(second_alias_node))
开发者ID:mwilliamson,项目名称:nope,代码行数:7,代码来源:name_resolution_tests.py


示例7: test_with_out_keyword

def test_with_out_keyword():
    """Test with out keyword."""
    out = np.empty((1, 4))
    rtn = rmg.calculate_gradient_across_cell_corners(
        values_at_nodes, 5, out=out)
    assert_is(rtn, out)
    assert_array_equal(out, np.array([[6., 4., -6., -4.]]) / np.sqrt(2))
开发者ID:Fooway,项目名称:landlab,代码行数:7,代码来源:test_gradients_across_cell_corners.py


示例8: test_create_basic

def test_create_basic():
    assert_is(type(std_bal), Balance)
    assert_equal(len(std_bal), len(movements))
    assert len(std_bal) == 3
    assert_equal(std_bal[0]['money'], 100)
    assert_equal(std_bal[1]['money'], 0)
    assert_equal(std_bal[2]['money'], -20)
开发者ID:boyska,项目名称:spycci,代码行数:7,代码来源:test_balance_basic.py


示例9: exception_handler_targets_cannot_be_accessed_from_nested_function

def exception_handler_targets_cannot_be_accessed_from_nested_function():
    target_node = nodes.ref("error")
    ref_node = nodes.ref("error")
    body = [nodes.ret(ref_node)]
    func_node = nodes.func("f", nodes.arguments([]), body, type=None)
    try_node = nodes.try_(
        [],
        handlers=[
            nodes.except_(nodes.none(), target_node, [func_node])
        ],
    )
    
    declaration = name_declaration.ExceptionHandlerTargetNode("error")
    references = References([
        (target_node, declaration),
        (ref_node, declaration),
        (func_node, name_declaration.VariableDeclarationNode("f")),
    ])
    
    try:
        _updated_bindings(try_node, references=references)
        assert False, "Expected error"
    except errors.UnboundLocalError as error:
        assert_equal(ref_node, error.node)
        assert_is("error", error.name)
开发者ID:mwilliamson,项目名称:nope,代码行数:25,代码来源:name_binding_tests.py


示例10: test_computeDescriptor_validType_existingVector_overwrite

    def test_computeDescriptor_validType_existingVector_overwrite(self):
        expected_image_type = 'image/png'
        expected_existing_vector = numpy.random.randint(0, 100, 10)
        expected_new_vector = numpy.random.randint(0, 100, 10)
        expected_uuid = "a unique ID"

        # Set up mock classes/responses
        mDataElement = mock.Mock(spec=smqtk.representation.DataElement)
        m_data = mDataElement()
        m_data.content_type.return_value = expected_image_type
        m_data.uuid.return_value = expected_uuid

        mDescrElement = mock.Mock(spec=smqtk.representation.DescriptorElement)
        mDescrElement().has_vector.return_value = True
        mDescrElement().vector.return_value = expected_existing_vector

        mDescriptorFactory = mock.Mock(spec=smqtk.representation.DescriptorElementFactory)
        m_factory = mDescriptorFactory()
        m_factory.new_descriptor.return_value = mDescrElement()

        cd = DummyDescriptorGenerator()
        cd.valid_content_types = mock.Mock(return_value={expected_image_type})
        cd._compute_descriptor = mock.Mock(return_value=expected_new_vector)

        # Call: matching content types, existing descriptor for data
        d = cd.compute_descriptor(m_data, m_factory, overwrite=True)

        ntools.assert_false(mDescrElement().has_vector.called)
        ntools.assert_true(cd._compute_descriptor.called)
        cd._compute_descriptor.assert_called_once_with(m_data)
        ntools.assert_true(mDescrElement().set_vector.called)
        mDescrElement().set_vector.assert_called_once_with(expected_new_vector)
        ntools.assert_is(d, mDescrElement())
开发者ID:kod3r,项目名称:SMQTK,代码行数:33,代码来源:test_DG_abstract.py


示例11: test_initialize_reset_scheme

def test_initialize_reset_scheme():
	solver = Solver(Scheme_init_once(.1), System(f))
	solver.initialize(u0=1., name='first')
	nt.assert_is(solver.current_scheme, None)
	solver.run(1.)
	solver.initialize(u0=2.,name='second')
	solver.run(1.)
开发者ID:bjodah,项目名称:odelab,代码行数:7,代码来源:test_solver.py


示例12: test_request_is_passed_through_on_post

    def test_request_is_passed_through_on_post(self):
        request = object()
        form = FlatCommentMultiForm(self.content_object, self.user, data={'comment': 'Works!'})
        form.post(request)

        tools.assert_equals(1, len(self._posted))
        tools.assert_is(request, self._posted[0][1]['request'])
开发者ID:whalerock,项目名称:ella-flatcomments,代码行数:7,代码来源:test_forms.py


示例13: test_getitem

 def test_getitem(self):
     assert_is_not(self.adjview[1], self.s[1])
     assert_is(self.adjview[0][7], self.adjview[0][3])
     assert_equal(self.adjview[2]['key']['color'], 1)
     assert_equal(self.adjview[2][1]['span'], 2)
     assert_raises(KeyError, self.adjview.__getitem__, 4)
     assert_raises(KeyError, self.adjview[1].__getitem__, 'key')
开发者ID:ProgVal,项目名称:networkx,代码行数:7,代码来源:test_coreviews.py


示例14: test_from_json

def test_from_json():
    '''basic test of JSON deserialization'''
    s_json = '''{
      "__class__": "sysdiag.System",
      "__sysdiagclass__": "System",
      "name": "my syst",
      "params": {},
      "ports": [],
      "subsystems": [],
      "wires": []
    }'''
    s = sysdiag.json_load(s_json)
    assert_is(type(s), sysdiag.System)
    assert_equal(s.name, "my syst")

    # Test a port:
    p_json = '''{
      "__class__": "sysdiag.Port",
      "__sysdiagclass__": "Port",
      "name": "my port",
      "type": ""
    }'''
    p = sysdiag.json_load(p_json)
    assert_is(type(p), sysdiag.Port)
    assert_equal(p.name, "my port")

    # Test a wire:
    w_json = '''{
开发者ID:pierre-haessig,项目名称:sysdiag,代码行数:28,代码来源:test_sysdiag.py


示例15: test_get_component_by_component

 def test_get_component_by_component(self):
     m = self.model
     g1 = hs.model.components.Gaussian()
     g2 = hs.model.components.Gaussian()
     g2.name = "test"
     m.extend((g1, g2))
     nt.assert_is(m._get_component(g2), g2)
开发者ID:siriagus,项目名称:hyperspy,代码行数:7,代码来源:test_model.py


示例16: test_with_mixins

def test_with_mixins():
    # Testing model metaclass with mixins
    class FieldsMixin(object):
        """Toy class for field testing"""
        field_a = Integer(scope=Scope.settings)

    class BaseClass(object):
        """Toy class for ModelMetaclass testing"""
        __metaclass__ = ModelMetaclass

    class ChildClass(FieldsMixin, BaseClass):
        """Toy class for ModelMetaclass and field testing"""
        pass

    class GrandchildClass(ChildClass):
        """Toy class for ModelMetaclass and field testing"""
        pass

    # `ChildClass` and `GrandchildClass` both obtain the `fields` attribute
    # from the `ModelMetaclass`. Since this is not understood by static analysis,
    # silence this error for the duration of this test.
    # pylint: disable=E1101

    assert hasattr(ChildClass, 'field_a')
    assert_is(ChildClass.field_a, ChildClass.fields['field_a'])

    assert hasattr(GrandchildClass, 'field_a')
    assert_is(GrandchildClass.field_a, GrandchildClass.fields['field_a'])
开发者ID:qvin,项目名称:XBlock,代码行数:28,代码来源:test_core.py


示例17: class_definition_base_classes_are_resolved

def class_definition_base_classes_are_resolved():
    ref = nodes.ref("object")
    node = nodes.class_("User", [], base_classes=[ref])
    
    declarations = _create_declarations(["User", "object"])
    references = resolve(node, declarations)
    assert_is(declarations.declaration("object"), references.referenced_declaration(ref))
开发者ID:mwilliamson,项目名称:nope,代码行数:7,代码来源:name_resolution_tests.py


示例18: test_model_navigation_indexer_slice

    def test_model_navigation_indexer_slice(self):
        self.model.axes_manager.indices = (0, 0)
        self.model[0].active = False

        # Make sure the array we copy has been appropriatelly updated before
        # slicing
        _test = self.model[0]._active_array[0, 0]
        while _test:
            time.sleep(0.1)
            _test = self.model[0]._active_array[0, 0]

        m = self.model.inav[0::2]
        np.testing.assert_array_equal(
            m.chisq.data, self.model.chisq.data[:, 0::2])
        np.testing.assert_array_equal(m.dof.data, self.model.dof.data[:, 0::2])
        nt.assert_is(m.inav[:2][0].A.ext_force_positive,
                     m[0].A.ext_force_positive)
        nt.assert_equal(m.chisq.data.shape, (4, 2))
        nt.assert_false(m[0]._active_array[0, 0])
        for ic, c in enumerate(m):
            np.testing.assert_equal(
                c._active_array,
                self.model[ic]._active_array[:, 0::2])
            for p_new, p_old in zip(c.parameters, self.model[ic].parameters):
                nt.assert_true((p_old.map[:, 0::2] == p_new.map).all())
开发者ID:siriagus,项目名称:hyperspy,代码行数:25,代码来源:test_fancy_indexing.py


示例19: _test

 def _test():
     rmg = RasterModelGrid(4, 5)
     number_of_elements = rmg.number_of_elements(element)
     rtn_values = rmg.add_ones(element, 'name')
     assert_is(rtn_values, rmg.field_values(element, 'name'))
     assert_array_equal(
         rtn_values, np.ones(number_of_elements, dtype=np.float))
开发者ID:Kirubaharan,项目名称:landlab,代码行数:7,代码来源:test_allocators.py


示例20: test_translationservice

def test_translationservice():
    """Test TranslationService prototype."""
    machine = TranslationService()
    assert_is_instance(machine._state, ExampleLayer)

    # Test ExampleLayer with chord
    event = ProtoKeyEvent(event='down', switch_vector=[1, 0, 1], is_chord=True)
    expected_char = 'c'
    expected_event = 'down'

    observed_char, observed_event = machine.process_protokey_event(event)

    assert_equals(expected_char, observed_char)
    assert_equals(expected_event, observed_event)

    # Test ExampleLayer with single switch
    event = ProtoKeyEvent(event='up', switch_vector=[0, 1, 0], is_chord=True)
    expected_char = 'd'
    expected_event = 'up'

    observed_char, observed_event = machine.process_protokey_event(event)

    assert_equals(expected_char, observed_char)
    assert_equals(expected_event, observed_event)

    # Do a reset
    event = ProtoKeyEvent(
        event='reset',
        switch_vector=[1, 1, 1],
        is_chord=True)
    expected_char = 'EmptyKey'
    expected_event = 'reset'

    observed_char, observed_event = machine.process_protokey_event(event)

    assert_equals(expected_char, observed_char)
    assert_equals(expected_event, observed_event)

    # This should be ignored - accumulating!
    event = ProtoKeyEvent(
        event='down',
        switch_vector=[1, 0, 0],
        is_chord=False)
    observed = machine.process_protokey_event(event)
    assert_is(observed, None)

    # Switch layer (right now there's no key for that!)
    machine._state = ExampleNonChordedLayer()

    event = ProtoKeyEvent(
        event='down',
        switch_vector=[0, 0, 1],
        is_chord=False)
    expected_char = 'c'
    expected_event = 'down'

    observed_char, observed_event = machine.process_protokey_event(event)

    assert_equals(expected_char, observed_char)
    assert_equals(expected_event, observed_event)
开发者ID:Humanity4all,项目名称:AsetNiop4Teensy,代码行数:60,代码来源:test_translationservice.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tools.assert_is_instance函数代码示例发布时间:2022-05-27
下一篇:
Python tools.assert_in函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap