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

Python samples.SampleBase类代码示例

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

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



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

示例1: test_expect_bound_method_with_allof_comparator

  def test_expect_bound_method_with_allof_comparator(self):
    obj = SampleBase()
    expect(obj.bound_method).args( all_of(length(5),'hello') )
    obj.bound_method( 'hello' )

    expect(obj.bound_method).args( all_of(length(3),'hello') ).at_least(0)
    assert_raises(UnexpectedCall, obj.bound_method, 'hello' )
开发者ID:ods94065,项目名称:chai,代码行数:7,代码来源:sample_test.py


示例2: test_expects_class_method

  def test_expects_class_method(self):
    expect(SampleBase.a_classmethod).returns(12)
    assert_equals(12, SampleBase.a_classmethod())

    obj = SampleBase()
    expect(SampleBase.a_classmethod).returns(100)
    assert_equals(100, obj.a_classmethod())
开发者ID:ods94065,项目名称:chai,代码行数:7,代码来源:sample_test.py


示例3: test_expects_bound_method_at_most

 def test_expects_bound_method_at_most(self):
   obj = SampleBase()
   expect(obj.bound_method).args(1, 2).returns(12).at_most(3)
   assert_equals(12, obj.bound_method(1, 2))
   assert_equals(12, obj.bound_method(1, 2))
   obj.bound_method(1, 2)
   assert_raises(UnexpectedCall, obj.bound_method, 1, 2)
开发者ID:ods94065,项目名称:chai,代码行数:7,代码来源:sample_test.py


示例4: test_expects_bound_method_at_least_as_last_expectation

 def test_expects_bound_method_at_least_as_last_expectation(self):
   obj = SampleBase()
   expect(obj.bound_method).args(1, 2).returns(12).at_least(3)
   assert_equals(12, obj.bound_method(1, 2))
   assert_equals(12, obj.bound_method(1, 2))
   assert_equals(12, obj.bound_method(1, 2))
   assert_equals(12, obj.bound_method(1, 2))
开发者ID:ods94065,项目名称:chai,代码行数:7,代码来源:sample_test.py


示例5: tests_expects_bound_method_any_order_with_fixed_maxes

 def tests_expects_bound_method_any_order_with_fixed_maxes(self):
   obj = SampleBase()
   expect(obj.bound_method).args(1).returns(2).any_order()
   expect(obj.bound_method).args(3).returns(4).any_order()
   assert_equals(4, obj.bound_method(3) )
   assert_equals(2, obj.bound_method(1) )
   assert_raises(UnexpectedCall, obj.bound_method, 1)
开发者ID:ods94065,项目名称:chai,代码行数:7,代码来源:sample_test.py


示例6: test_expects_bound_method_returns

  def test_expects_bound_method_returns(self):
    obj = SampleBase()
    expect(obj.bound_method).args(1, 2).returns(12)
    assert_equals(12, obj.bound_method(1, 2))

    expect(obj.bound_method).args(1, 4).returns(1100)
    assert_equals(1100, obj.bound_method(1, 4))
开发者ID:ods94065,项目名称:chai,代码行数:7,代码来源:sample_test.py


示例7: test_expects_bound_method_can_be_used_for_iterative_testing

  def test_expects_bound_method_can_be_used_for_iterative_testing(self):
    obj = SampleBase()
    expect(obj.bound_method).args(1, 2).returns(12)
    assert_equals(12, obj.bound_method(1, 2))
    assert_raises(UnexpectedCall, obj.bound_method)

    expect(obj.bound_method).args(1, 4).returns(1100)
    assert_equals(1100, obj.bound_method(1, 4))
开发者ID:ods94065,项目名称:chai,代码行数:8,代码来源:sample_test.py


示例8: test_expects_any_order_without_count_modifiers

 def test_expects_any_order_without_count_modifiers(self):
   obj = SampleBase()
   expect(obj.bound_method).args(3).returns(4)
   expect(obj.bound_method).args(1).returns(2).any_order()
   expect(obj.bound_method).args(3).returns(4)
   assert_equals(4, obj.bound_method(3) )
   assert_equals(4, obj.bound_method(3) )
   assert_equals(2, obj.bound_method(1) )
开发者ID:ods94065,项目名称:chai,代码行数:8,代码来源:sample_test.py


示例9: test_add_to_list_with_module_mock_object

  def test_add_to_list_with_module_mock_object(self):
    mock( samples, 'deque' )
    deq = mock()
    expect( samples.deque.__call__ ).returns( deq )
    expect( deq.append ).args('value')

    obj = SampleBase()
    obj.add_to_list('value')
开发者ID:ods94065,项目名称:chai,代码行数:8,代码来源:sample_test.py


示例10: test_expect_unbound_method_acts_as_any_instance

  def test_expect_unbound_method_acts_as_any_instance(self):
    expect( SampleBase.bound_method ).args('hello').returns('world')
    expect( SampleBase.bound_method ).args('hello').returns('mars')

    obj1 = SampleBase()
    obj2 = SampleBase()
    assert_equals( 'world', obj2.bound_method('hello') )
    assert_equals( 'mars', obj1.bound_method('hello') )
    assert_raises(UnexpectedCall, obj2.bound_method)
开发者ID:ods94065,项目名称:chai,代码行数:9,代码来源:sample_test.py


示例11: test_expects_bound_method_at_least_with_other_expectation_and_anyorder

  def test_expects_bound_method_at_least_with_other_expectation_and_anyorder(self):
    obj = SampleBase()
    expect(obj.bound_method).args(1, 2).returns(12).at_least(2).any_order()
    assert_equals(12, obj.bound_method(1, 2))
    assert_equals(12, obj.bound_method(1, 2))

    expect(obj.bound_method).args(1, 3).returns(100)
    assert_equals(100, obj.bound_method(1, 3))
    
    assert_equals(12, obj.bound_method(1, 2))
开发者ID:ods94065,项目名称:chai,代码行数:10,代码来源:sample_test.py


示例12: tests_expects_bound_method_any_order_with_mins

 def tests_expects_bound_method_any_order_with_mins(self):
   obj = SampleBase()
   expect(obj.bound_method).args(1).returns(2).any_order().at_least_once()
   expect(obj.bound_method).args(3).returns(4).any_order().at_least_once()
   assert_equals(4, obj.bound_method(3) )
   assert_equals(2, obj.bound_method(1) )
   assert_equals(4, obj.bound_method(3) )
   assert_equals(2, obj.bound_method(1) )
   assert_equals(2, obj.bound_method(1) )
   assert_equals(4, obj.bound_method(3) )
   assert_equals(2, obj.bound_method(1) )
开发者ID:ods94065,项目名称:chai,代码行数:11,代码来源:sample_test.py


示例13: test_expect_bound_method_with_anyof_comparator

 def test_expect_bound_method_with_anyof_comparator(self):
   obj = SampleBase()
   expect(obj.bound_method).times(4).args(
     any_of(int, 3.14, 'hello', is_a(list)))
   obj.bound_method(42)
   obj.bound_method(3.14)
   obj.bound_method('hello')
   obj.bound_method([1, 2, 3])
   assert_raises(UnexpectedCall, obj.bound_method, '42')
开发者ID:agoragames,项目名称:chai,代码行数:9,代码来源:sample_test.py


示例14: test_var_comparator

  def test_var_comparator(self):
    obj = SampleBase()
    expect(obj.add_to_list).args( var('value1') )
    expect(obj.add_to_list).args( var('value2') )
    expect(obj.add_to_list).args( var('value3') ).at_least_once()

    obj.add_to_list('v1')
    obj.add_to_list('v2')
    obj.add_to_list('v3')
    obj.add_to_list('v3')
    self.assertRaises( UnexpectedCall, obj.add_to_list, 'v3a')

    assert_equals( 'v1', var('value1').value )
    assert_equals( 'v2', var('value2').value )
    assert_equals( 'v3', var('value3').value )
开发者ID:ods94065,项目名称:chai,代码行数:15,代码来源:sample_test.py


示例15: test_spy

  def test_spy(self):
    spy(SampleBase)
    obj = SampleBase()
    assert_true(isinstance(obj,SampleBase))

    spy(obj.add_to_list)
    obj.add_to_list('v1')
    assert_equals(['v1'], list(obj._deque))

    spy(obj.add_to_list).args( var('value2') )
    obj.add_to_list('v2')
    assert_equals(['v1','v2'], list(obj._deque))
    assert_equals( 'v2', var('value2').value )

    # Have to use times(0) because we don't actually expect this to be called
    with assert_raises(UnsupportedModifier):
        spy(obj.add_to_list).times(0).side_effect(lambda x: x)
    with assert_raises(UnsupportedModifier):
        spy(obj.add_to_list).times(0).returns(3)
    with assert_raises(UnsupportedModifier):
        spy(obj.add_to_list).times(0).raises(Exception('oops'))
开发者ID:wrwrwr,项目名称:chai,代码行数:21,代码来源:sample_test.py


示例16: test_expect_bound_method_with_equals_comparator

 def test_expect_bound_method_with_equals_comparator(self):
   obj = SampleBase()
   expect(obj.bound_method).args( equals(42) )
   obj.bound_method( 42 )
   assert_raises(UnexpectedCall, obj.bound_method, 32 )
开发者ID:ods94065,项目名称:chai,代码行数:5,代码来源:sample_test.py


示例17: test_expect_bound_method_with_is_a_comparator

 def test_expect_bound_method_with_is_a_comparator(self):
   obj = SampleBase()
   expect(obj.bound_method).args( is_a(int) )
   obj.bound_method( 42 )
   assert_raises(UnexpectedCall, obj.bound_method, '42' )
开发者ID:ods94065,项目名称:chai,代码行数:5,代码来源:sample_test.py


示例18: test_expect_bound_method_with_notof_comparator_using_types

 def test_expect_bound_method_with_notof_comparator_using_types(self):
   obj = SampleBase()
   expect(obj.bound_method).args( not_of(float,int) )
   obj.bound_method( 'hello' )
开发者ID:ods94065,项目名称:chai,代码行数:4,代码来源:sample_test.py


示例19: test_expect_callback

 def test_expect_callback(self):
   obj = SampleBase()
   expect(obj.callback_target)
   obj.callback_source()
开发者ID:ods94065,项目名称:chai,代码行数:4,代码来源:sample_test.py


示例20: test_is_comparator

 def test_is_comparator(self):
   obj = SampleBase()
   expect(obj.bound_method).args(is_arg(obj)).returns(100)
   assert_equals(obj.bound_method(obj), 100)
开发者ID:ods94065,项目名称:chai,代码行数:4,代码来源:sample_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sandbox.mrjob_conf_patcher函数代码示例发布时间:2022-05-27
下一篇:
Python sampledata.SampleData类代码示例发布时间: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