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


Python tools.assert_is函数代码示例

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


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


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