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

Python trivial.assert_equal函数代码示例

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

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



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

示例1: test_area

    def test_area(self):

        assert_equal(integrate_f_over_polygon_code(1).splitlines(),
                     'def ifxy(pts):\n    "Integrate f = 1 over '
                     'polygon"\n\n    x, y, z = xyz_from_pts(pts, True)'
                     '\n\n    return np.sum((x[:-1]/2 + x[1:]/2)*(-y[:-1] '
                     '+ y[1:]))'.splitlines())
开发者ID:mikyes,项目名称:geotecha,代码行数:7,代码来源:test_geometry.py


示例2: test_to_dict_recursive_circular

def test_to_dict_recursive_circular():

    class Brother(TInterface):

        _dict_attrs = (
            'name',
            'siblings'
        )

        def __init__(self, name):
            self.name = name
            self.siblings = []

        def __repr__(self):
            return 'Brother: %s' % (self.name)

    tom = Brother('tom')
    jerry = Brother('jerry')
    tom.siblings.append(jerry)
    jerry.siblings.append(tom)

    result = to_dict_recursive(tom)
    result2 = to_dict_recursive(jerry)

    assert_equal(
        result,
        {'name': 'tom', 'siblings': [{'name': 'jerry', 'siblings': []}]}
    )

    assert_equal(
        result2,
        {'name': 'jerry', 'siblings': [{'name': 'tom', 'siblings': []}]}
    )
开发者ID:petermelias,项目名称:mrpython,代码行数:33,代码来源:test_fxn.py


示例3: test_defaults

    def test_defaults(self):
        fig = plot_single_material_vs_depth((self.a, self.b), self.xlabels)

        assert_equal(len(fig.get_axes()), 2)
        ax1 = fig.get_axes()[0]
        line1= ax1.get_lines()[0]

        ax2 = fig.get_axes()[1]
        line2 = ax2.get_lines()[0]

        assert_allclose(line1.get_xydata()[0],
                     np.array([ 1., 0.]))
        assert_allclose(line1.get_xydata()[-1],
                     np.array([ 2., 1]))

        assert_allclose(line2.get_xydata()[0],
                     np.array([ 2., 0.]))
        assert_allclose(line2.get_xydata()[-1],
                     np.array([ 3., 1]))

        assert_equal(ax1.get_xlabel(), 'a')
        assert_equal(ax2.get_xlabel(), 'b')

        assert_equal(ax1.get_ylabel(), 'Depth, z')
        assert_equal(ax2.get_ylabel(), '')
开发者ID:mikyes,项目名称:geotecha,代码行数:25,代码来源:test_one_d.py


示例4: test_initialize_objects_attributes

def test_initialize_objects_attributes():
    """test for initialize_objects_attributes function"""
    #initialize_objects_attributes(obj, attributes=[], defaults = dict(),  not_found_value = None):

    a = EmptyClass()
    initialize_objects_attributes(a,attributes=['a','b'], defaults={'a': 6})
    assert_equal([a.a,a.b],[6,None])
开发者ID:rtrwalker,项目名称:geotecha,代码行数:7,代码来源:test_inputoutput.py


示例5: test_prop_dict_ylabel

    def test_prop_dict_ylabel(self):
        fig = plot_single_material_vs_depth((self.a, self.b),
                                            self.xlabels,
                                            prop_dict={'ylabel': 'hello'})
        ax1 = fig.get_axes()[0]

        assert_equal(ax1.get_ylabel(), 'hello')
开发者ID:mikyes,项目名称:geotecha,代码行数:7,代码来源:test_one_d.py


示例6: test_save_data_input_text

 def test_save_data_input_text(self):
     a = InputFileLoaderCheckerSaver()
     a._input_text= "hello"
     a.save_data_to_file=True
     a._save_data()
     assert_equal(self.tempdir.read(
             ('out0002','out0002_input_original.py'), 'utf-8').strip().splitlines(),
                  'hello'.splitlines())
开发者ID:rtrwalker,项目名称:geotecha,代码行数:8,代码来源:test_inputoutput.py


示例7: test_propdict_has_legend

    def test_propdict_has_legend(self):


        fig = plot_vs_depth(self.x, self.z, ['a', 'b', 'c'],
                           prop_dict={'has_legend': False})
        ax = fig.get_axes()[0]

        assert_equal(ax.get_legend(), None)
开发者ID:mikyes,项目名称:geotecha,代码行数:8,代码来源:test_one_d.py


示例8: test_check_attributes_to_force_same_len

    def test_check_attributes_to_force_same_len(self):
        a = InputFileLoaderCheckerSaver()
        a.a = [4,5]
        a.c=None
        a._attributes_to_force_same_len = ['a c'.split()]
        a.check_input_attributes()

        assert_equal(a.c, [None, None])
开发者ID:rtrwalker,项目名称:geotecha,代码行数:8,代码来源:test_inputoutput.py


示例9: test_propdict_legend_prop_title

 def test_propdict_legend_prop_title(self):
     fig = plot_generic_loads([[self.triple1], [self.triple2]],
                               load_names=self.load_names,
                        prop_dict={'legend_prop':{'title':'abc'}})
     ax1 = fig.get_axes()[0]
     ax3 = fig.get_axes()[2]
     assert_equal(ax1.get_legend().get_title().get_text(), 'abc')
     assert_equal(ax3.get_legend().get_title().get_text(), 'abc')
开发者ID:mikyes,项目名称:geotecha,代码行数:8,代码来源:test_one_d.py


示例10: test_copy_dict

def test_copy_dict():
    """test for copy_dict"""
    #copy_dict(source_dict, diffs)
#    ok_(copy_dict({'a':7, 'b':12}, {'c':13})=={'a':7, 'b':12, 'c':13})
    assert_equal(copy_dict({'a':7, 'b':12}, {'c':13}),
                 {'a':7, 'b':12, 'c':13})
#    ok_(copy_dict({'a':7, 'b':12}, {'a':21, 'c':13})=={'a':21, 'b':12, 'c':13})
    assert_equal(copy_dict({'a':7, 'b':12}, {'a':21, 'c':13}),
                 {'a':21, 'b':12, 'c':13})
开发者ID:mikyes,项目名称:geotecha,代码行数:9,代码来源:test_one_d.py


示例11: test_check_attributes_that_should_be_lists

    def test_check_attributes_that_should_be_lists(self):
        a = InputFileLoaderCheckerSaver()
        a.a=4
        a.b=6
        a._attributes_that_should_be_lists = ['b']
        a.check_input_attributes()

        assert_equal(a.a, 4)
        assert_equal(a.b, [6])
开发者ID:rtrwalker,项目名称:geotecha,代码行数:9,代码来源:test_inputoutput.py


示例12: test_propdict_xylabels

    def test_propdict_xylabels(self):


        fig = plot_vs_depth(self.x, self.z, ['a', 'b', 'c'],
                           prop_dict={'xlabel':'xxx', 'ylabel':'yyy'})
        ax = fig.get_axes()[0]

        assert_equal(ax.get_xlabel(), 'xxx')
        assert_equal(ax.get_ylabel(), 'yyy')
开发者ID:mikyes,项目名称:geotecha,代码行数:9,代码来源:test_one_d.py


示例13: test_split_sequence_into_dict_and_nondicts

def test_split_sequence_into_dict_and_nondicts():
    """test for split_sequence_into_dict_and_nondicts"""
    #split_sequence_into_dict_and_nondicts(*args)

    assert_equal(split_sequence_into_dict_and_nondicts({'a': 2, 'b': 3},
                                   4,
                                   {'a':8, 'c':5},
                                   5),
                                   ([4,5], {'a': 8, 'b': 3, 'c':5}))
开发者ID:mikyes,项目名称:geotecha,代码行数:9,代码来源:test_one_d.py


示例14: test_prop_dict_depth_axis_label

    def test_prop_dict_depth_axis_label(self):
        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                  load_names=self.load_names,
                           prop_dict={'depth_axis_label': 'hello'})

        ax2 = fig.get_axes()[1]
        ax4 = fig.get_axes()[3]
        assert_equal(ax2.get_xlabel(), '')
        assert_equal(ax4.get_xlabel(), 'hello')
开发者ID:mikyes,项目名称:geotecha,代码行数:9,代码来源:test_one_d.py


示例15: test_prop_dict_time_axis_label

    def test_prop_dict_time_axis_label(self):
        fig = plot_generic_loads([[self.triple1], [self.triple2]],
                                  load_names=self.load_names,
                           prop_dict={'time_axis_label': 'hello'})

        ax1 = fig.get_axes()[0]
        ax3 = fig.get_axes()[2]
        assert_equal(ax1.get_xlabel(), '')
        assert_equal(ax3.get_xlabel(), 'hello')
开发者ID:mikyes,项目名称:geotecha,代码行数:9,代码来源:test_one_d.py


示例16: test_copy_attributes_from_text_to_object

def test_copy_attributes_from_text_to_object():
    """test for copy_attributes_from_text_to_object function"""
    #copy_attributes_from_text_to_object(reader,*args, **kwargs)
    reader = textwrap.dedent("""\
        a = 2
        b = 3
        """)
    a = EmptyClass()
    copy_attributes_from_text_to_object(reader,a,['a','b', 'aa', 'bb'], {'bb': 27})
    assert_equal([a.a, a.b, a.aa, a.bb], [2, 3, None, 27])
开发者ID:rtrwalker,项目名称:geotecha,代码行数:10,代码来源:test_inputoutput.py


示例17: test_if_else

def test_if_else():
	if_else_validator = konval.IfElse(konval.types.IsType(str), konval.types.ToType(str))

	string_value = '1234'

	assert_equal(if_else_validator(string_value), string_value)

	numerical_value = 1234

	assert_equal(if_else_validator(numerical_value), string_value)
开发者ID:agapow,项目名称:py-konval,代码行数:10,代码来源:test_konval.py


示例18: test_default

def test_default():
	default_validator = konval.Default(konval.types.IsType(str), 'NOT A STRING!')

	string_value = '1234'

	assert_equal(default_validator(string_value), string_value)

	numerical_value = 1234

	assert_equal(default_validator(numerical_value), 'NOT A STRING!')
开发者ID:agapow,项目名称:py-konval,代码行数:10,代码来源:test_konval.py


示例19: test_if

def test_if():
	if_validator = konval.If(True, konval.types.ToType(int))

	numerical_string = '1234'

	assert_equal(if_validator(numerical_string), 1234)

	if_validator = konval.If(False, konval.types.ToType(int))

	assert_equal(if_validator(numerical_string), numerical_string)
开发者ID:agapow,项目名称:py-konval,代码行数:10,代码来源:test_konval.py


示例20: test_plot_args_marker

    def test_plot_args_marker(self):
        fig = plt.figure()
        data = [([self.xa1, self.ya1,{'marker': 's'}], [self.xa2, self.ya2]),
                ([self.xb1, self.yb1],)]

        plot_data_in_grid(fig, data, self.gs)

        assert_equal(len(fig.get_axes()), 2)
        ax1 = fig.get_axes()[0]
        line1 = ax1.get_lines()[0]
        assert_equal(line1.get_marker(), 's')
开发者ID:mikyes,项目名称:geotecha,代码行数:11,代码来源:test_one_d.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python trivial.assert_raises函数代码示例发布时间:2022-05-27
下一篇:
Python tools.with_setup函数代码示例发布时间: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