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

Python deprecated.that函数代码示例

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

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



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

示例1: test_that_checking_each_matches

def test_that_checking_each_matches():
    "that(iterable).in_each('').equals('value')"

    class animal(object):
        def __init__(self, kind):
            self.attributes = {"class": "mammal", "kind": kind}

    animals = [animal("dog"), animal("cat"), animal("cow"), animal("cow"), animal("cow")]

    assert animals[0].attributes["kind"] != "cow"
    assert animals[1].attributes["kind"] != "cow"

    assert animals[2].attributes["kind"] == "cow"
    assert animals[3].attributes["kind"] == "cow"
    assert animals[4].attributes["kind"] == "cow"

    assert animals[0].attributes["class"] == "mammal"
    assert animals[1].attributes["class"] == "mammal"
    assert animals[2].attributes["class"] == "mammal"
    assert animals[3].attributes["class"] == "mammal"
    assert animals[4].attributes["class"] == "mammal"

    assert that(animals).in_each("attributes['class']").matches("mammal")
    assert that(animals).in_each("attributes['class']").matches(["mammal", "mammal", "mammal", "mammal", "mammal"])

    assert that(animals).in_each("attributes['kind']").matches(["dog", "cat", "cow", "cow", "cow"])

    try:
        assert that(animals).in_each("attributes['kind']").matches(["dog"])
        assert False, "should not reach here"
    except AssertionError as e:
        assert that(text_type(e)).equals(
            "%r has 5 items, but the matching list has 1: %r" % (["dog", "cat", "cow", "cow", "cow"], ["dog"])
        )
开发者ID:vmalloc,项目名称:sure,代码行数:34,代码来源:test_old_api.py


示例2: test_that_something_iterable_matches_another

def test_that_something_iterable_matches_another():
    "that(something_iterable).matches(another_iterable)"

    KlassOne = type('KlassOne', (object,), {})
    KlassTwo = type('KlassTwo', (object,), {})
    one = [
        ("/1", KlassOne),
        ("/2", KlassTwo),
    ]

    two = [
        ("/1", KlassOne),
        ("/2", KlassTwo),
    ]

    assert that(one).matches(two)
    assert that(one).equals(two)

    def fail_1():
        assert that(range(1)).matches(xrange(2))

    class Fail2(object):
        def __init__(self):
            assert that(xrange(1)).matches(range(2))

    class Fail3(object):
        def __call__(self):
            assert that(xrange(1)).matches(range(2))

    assert that(fail_1).raises('X is a list and Y is a xrange instead')
    assert that(Fail2).raises('X is a xrange and Y is a list instead')
    assert that(Fail3()).raises('X is a xrange and Y is a list instead')
开发者ID:spulec,项目名称:sure,代码行数:32,代码来源:test_old_api.py


示例3: test_that_something_iterable_matches_another

def test_that_something_iterable_matches_another():
    "that(something_iterable).matches(another_iterable)"

    # types must be unicode in py3, bute bytestrings in py2
    KlassOne = type("KlassOne" if PY3 else b"KlassOne", (object,), {})
    KlassTwo = type("KlassTwo" if PY3 else b"KlassTwo", (object,), {})
    one = [("/1", KlassOne), ("/2", KlassTwo)]

    two = [("/1", KlassOne), ("/2", KlassTwo)]

    assert that(one).matches(two)
    assert that(one).equals(two)

    def fail_1():
        assert that([1]).matches(xrange(2))

    class Fail2(object):
        def __init__(self):
            assert that(xrange(1)).matches([2])

    class Fail3(object):
        def __call__(self):
            assert that(xrange(1)).matches([2])

    xrange_name = xrange.__name__
    assert that(fail_1).raises("X is a list and Y is a {0} instead".format(xrange_name))
    assert that(Fail2).raises("X is a {0} and Y is a list instead".format(xrange_name))
    assert that(Fail3()).raises("X is a {0} and Y is a list instead".format(xrange_name))
开发者ID:vmalloc,项目名称:sure,代码行数:28,代码来源:test_old_api.py


示例4: test_that_len_greater_than_should_raise_assertion_error

def test_that_len_greater_than_should_raise_assertion_error():
    "that() len_greater_than(number) raise AssertionError"

    lst = list(range(1000))
    try:
        that(lst).len_greater_than(1000)
    except AssertionError as e:
        assert_equals(str(e), "the length of the list should be greater then %d, but is %d" % (1000, 1000))
开发者ID:vmalloc,项目名称:sure,代码行数:8,代码来源:test_old_api.py


示例5: test_that_len_lower_than_or_equals_should_raise_assertion_error

def test_that_len_lower_than_or_equals_should_raise_assertion_error():
    "that() len_lower_than_or_equals(number) raise AssertionError"

    lst = list(range(1000))
    try:
        that(lst).len_lower_than_or_equals(100)
    except AssertionError as e:
        assert_equals(str(e), "the length of %r should be lower then or equals %d, but is %d" % (lst, 100, 1000))
开发者ID:vmalloc,项目名称:sure,代码行数:8,代码来源:test_old_api.py


示例6: test_that_len_is

def test_that_len_is():
    "that() len_is(number)"

    lst = range(1000)

    assert that(lst).len_is(1000)
    assert len(lst) == 1000
    assert that(lst).len_is(lst)
开发者ID:vmalloc,项目名称:sure,代码行数:8,代码来源:test_old_api.py


示例7: test_that_is_a_matcher_should_absorb_callables_to_be_used_as_matcher

def test_that_is_a_matcher_should_absorb_callables_to_be_used_as_matcher():
    u"that.is_a_matcher should absorb callables to be used as matcher"
    @that.is_a_matcher
    def is_truthful(what):
        assert bool(what), '%s is so untrue' % (what)
        return 'foobar'

    assert that('friend').is_truthful()
    assert_equals(that('friend').is_truthful(), 'foobar')
开发者ID:CyrilRoelandteNovance,项目名称:sure,代码行数:9,代码来源:test_old_api.py


示例8: test_that_len_greater_than

def test_that_len_greater_than():
    "that() len_greater_than(number)"

    lst = range(1000)
    lst2 = range(100)

    assert that(lst).len_greater_than(100)
    assert len(lst) == 1000
    assert that(lst).len_greater_than(lst2)
开发者ID:vmalloc,项目名称:sure,代码行数:9,代码来源:test_old_api.py


示例9: test_that_len_lower_than

def test_that_len_lower_than():
    "that() len_lower_than(number)"

    lst = list(range(100))
    lst2 = list(range(1000))

    assert that(lst).len_lower_than(101)
    assert len(lst) == 100
    assert that(lst).len_lower_than(lst2)
开发者ID:vmalloc,项目名称:sure,代码行数:9,代码来源:test_old_api.py


示例10: test_get_argv_options_integration

def test_get_argv_options_integration(context):
    u"Nose should parse sys.argv and figure out whether to run as integration"
    sys.argv = ['./manage.py', 'test', '--integration']
    runner = Nose()

    opts = runner.get_argv_options()
    assert that(opts['is_unit']).equals(False)
    assert that(opts['is_functional']).equals(False)
    assert that(opts['is_integration']).equals(True)
开发者ID:igorsobreira,项目名称:unclebob,代码行数:9,代码来源:test_nose_runner.py


示例11: test_get_argv_options_simple

def test_get_argv_options_simple(context):
    u"Nose should parse sys.argv"
    sys.argv = ['./manage.py', 'test']
    runner = Nose()

    opts = runner.get_argv_options()
    assert that(opts['is_unit']).equals(False)
    assert that(opts['is_functional']).equals(False)
    assert that(opts['is_integration']).equals(False)
开发者ID:igorsobreira,项目名称:unclebob,代码行数:9,代码来源:test_nose_runner.py


示例12: mock_get_paths_for

 def mock_get_paths_for(names, appending):
     k = expected_kinds.pop(0)
     assert that(names).is_a(list)
     assert that(appending).is_a(list)
     assert that(names).equals(['john', 'doe'])
     assert that(appending).equals(['tests', k])
     return [
         '/apps/john/tests/%s' % k,
         '/apps/doe/tests/%s' % k,
     ]
开发者ID:igorsobreira,项目名称:unclebob,代码行数:10,代码来源:test_nose_runner.py


示例13: test_that_is_a_matcher_should_absorb_callables_to_be_used_as_matcher

def test_that_is_a_matcher_should_absorb_callables_to_be_used_as_matcher():
    "that.is_a_matcher should absorb callables to be used as matcher"

    @that.is_a_matcher
    def is_truthful(what):
        assert bool(what), "%s is so untrue" % (what)
        return "foobar"

    assert that("friend").is_truthful()
    assert_equals(that("friend").is_truthful(), "foobar")
开发者ID:vmalloc,项目名称:sure,代码行数:10,代码来源:test_old_api.py


示例14: test_that_len_greater_than_or_equals_should_raise_assertion_error

def test_that_len_greater_than_or_equals_should_raise_assertion_error():
    "that() len_greater_than_or_equals(number) raise AssertionError"

    lst = range(1000)
    try:
        that(lst).len_greater_than_or_equals(1001)
    except AssertionError, e:
        assert_equals(
            str(e),
            'the length of %r should be greater then or equals %d, but is %d' \
            % (lst, 1001, 1000))
开发者ID:spulec,项目名称:sure,代码行数:11,代码来源:test_old_api.py


示例15: test_that_len_lower_than_or_equals

def test_that_len_lower_than_or_equals():
    "that() len_lower_than_or_equals(number)"

    lst = list(range(1000))
    lst2 = list(range(1001))

    assert that(lst).len_lower_than_or_equals(1001)
    assert that(lst).len_lower_than_or_equals(1000)
    assert len(lst) == 1000
    assert that(lst).len_lower_than_or_equals(lst2)
    assert that(lst).len_lower_than_or_equals(lst)
开发者ID:vmalloc,项目名称:sure,代码行数:11,代码来源:test_old_api.py


示例16: test_that_len_lower_than_should_raise_assertion_error

def test_that_len_lower_than_should_raise_assertion_error():
    "that() len_lower_than(number) raise AssertionError"

    lst = range(1000)
    try:
        that(lst).len_lower_than(1000)
    except AssertionError, e:
        assert_equals(
            str(e),
            'the length of %r should be lower then %d, but is %d' % \
            (lst, 1000, 1000))
开发者ID:spulec,项目名称:sure,代码行数:11,代码来源:test_old_api.py


示例17: test_that_at_key_equals

def test_that_at_key_equals():
    "that().at(object).equals(object)"

    class Class:
        name = "some class"

    Object = Class()
    dictionary = {"name": "John"}

    assert that(Class).at("name").equals("some class")
    assert that(Object).at("name").equals("some class")
    assert that(dictionary).at("name").equals("John")
开发者ID:vmalloc,项目名称:sure,代码行数:12,代码来源:test_old_api.py


示例18: test_that_at_key_equals

def test_that_at_key_equals():
    "that().at(object).equals(object)"

    class Class:
        name = "some class"
    Object = Class()
    dictionary = {
        'name': 'John',
    }

    assert that(Class).at("name").equals('some class')
    assert that(Object).at("name").equals('some class')
    assert that(dictionary).at("name").equals('John')
开发者ID:CyrilRoelandteNovance,项目名称:sure,代码行数:13,代码来源:test_old_api.py


示例19: test_raises_with_string

def test_raises_with_string():
    "that(callable).raises('message') should compare the message"

    def it_fails():
        assert False, 'should fail with this exception'

    try:
        that(it_fails).raises('wrong msg')
        raise RuntimeError('should not reach here')
    except AssertionError as e:
        assert that(text_type(e)).contains('''EXPECTED:
wrong msg

GOT:
should fail with this exception''')
开发者ID:CyrilRoelandteNovance,项目名称:sure,代码行数:15,代码来源:test_old_api.py


示例20: the_providers_are_working

    def the_providers_are_working(Then):
        Then.the_context_has_variables()
        assert hasattr(Then, 'var1')
        assert hasattr(Then, 'foobar')
        assert hasattr(Then, '__sure_providers_of__')

        providers = Then.__sure_providers_of__
        action = Then.the_context_has_variables.__name__

        providers_of_var1 = [p.__name__ for p in providers['var1']]
        assert that(providers_of_var1).contains(action)

        providers_of_foobar = [p.__name__ for p in providers['foobar']]
        assert that(providers_of_foobar).contains(action)

        return True
开发者ID:CyrilRoelandteNovance,项目名称:sure,代码行数:16,代码来源:test_old_api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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