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

Python tools.assert_eq函数代码示例

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

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



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

示例1: test_postings_file_get_entry_reset_false

def test_postings_file_get_entry_reset_false():
    filename = 'test'
    with PostingsFile(filename, 'w+') as pfile:
        head = pfile.pointer
        prev_ptr = head

        last = 12
        for i in xrange(1, last):
            current_entry = PostingsFileEntry(i)
            current_entry.own_pointer = pfile.pointer
            pfile.write_entry(current_entry)

            if i != last - 1:
                current_entry.next_pointer = pfile.pointer
                pfile.write_entry(current_entry)

        entries = []
        entry = pfile.get_entry(head, reset=False)
        while entry:
            entries.append(entry)
            entry = entry.next()
        entries = [entry.doc_id for entry in entries]
        assert_eq([1,2,3,4,5,6,7,8,9,10,11], entries)

    os.remove(filename)
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:25,代码来源:test_postings_file.py


示例2: test_postings_file_seek

def test_postings_file_seek():
    filename = 'test'
    with PostingsFile(filename, 'w+') as pfile:
        assert_eq(0, pfile.pointer)
        pfile.seek(10)
        assert_eq(10, pfile.pointer)
    os.remove(filename)
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:7,代码来源:test_postings_file.py


示例3: test_dot_product_generators

def test_dot_product_generators():
    vals = [0,1,2,3,4]
    v1 = (x for x in vals)
    v2 = (x for x in vals)
    assert_eq(
        1 + 4 + 9 + 16,
        dot_product(v1, v2))
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:7,代码来源:test_search_utils.py


示例4: test_runner_ascii

def test_runner_ascii(patched_func):
    cmd = ['cat', os.path.join(TEST_DIR,'ascii_text.txt')]
    for line in run_command(cmd):
        if type(line) == int:
            assert_eq(line, 0)
        else:
            assert_eq(line.rstrip(), 'Hello ASCII!')
开发者ID:simonlynen,项目名称:catkin_tools,代码行数:7,代码来源:test_runner.py


示例5: test_runner_unicode

def test_runner_unicode(patched_func):
    cmd = ['cat', os.path.join(TEST_DIR,'unicode_text.txt')]
    for line in run_command(cmd):
        if type(line) == int:
            assert_eq(line, 0)
        else:
            if line.rstrip() != 'Hello Unicode\u203d':
                print('WARNING: Unicode reading not supported!')
开发者ID:simonlynen,项目名称:catkin_tools,代码行数:8,代码来源:test_runner.py


示例6: test_unit_vector_generator

def test_unit_vector_generator():
    vals = [0,1,2,3,4]
    vector = (x for x in vals)
    length = math.sqrt(1 + 4 + 9 + 16)
    assert_eq(
        (float(0)/length, float(1)/length, float(2)/length, float(3)/length,
            float(4)/length),
        tuple(unit_vector(vector)))
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:8,代码来源:test_search_utils.py


示例7: test_ordered_dict_get_item

def test_ordered_dict_get_item():
    o = OrderedDict()
    o['a'] = 1
    o['b'] = 'asdf'

    assert_eq(1, o['a'])
    assert_eq(1, o.get('a'))
    assert_eq('asdf', o['b'])
    assert_eq('asdf', o.get('b'))
    assert_eq(None, o.get('c'))
开发者ID:jcheng31,项目名称:3245-homework-4,代码行数:10,代码来源:test_ordered_dict.py


示例8: test_cache_box_is_cached

def test_cache_box_is_cached():
    def test_func(x):
        return x

    cached_test_func = CacheBox(test_func)
    assert not cached_test_func.is_cached(5)

    assert_eq(5, cached_test_func(5))
    assert cached_test_func.is_cached(5)

    assert not cached_test_func.is_cached(4)
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:11,代码来源:test_cache.py


示例9: test_unit_vector_multiple

def test_unit_vector_multiple():
    vector = (1, 2)
    length = math.sqrt(1**2 + 2**2)
    assert_eq(
        (float(1)/length, float(2)/length),
        tuple(unit_vector(vector)))

    vector = (3, 5)
    length = math.sqrt(3**2 + 5**2)
    assert_eq(
        (float(3)/length, float(5)/length),
        tuple(unit_vector(vector)))
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:12,代码来源:test_search_utils.py


示例10: test_cache_decorators

def test_cache_decorators():
    @cached_function()
    def foo():
        return 1


    @cached_function(cache_size=10)
    def bar():
        return 1

    assert_eq('foo', foo.__name__)
    assert_eq('bar', bar.__name__)
开发者ID:ymichael,项目名称:py,代码行数:12,代码来源:test_cache.py


示例11: test_ordered_dict_set_item

def test_ordered_dict_set_item():
    o = OrderedDict()
    o['a'] = 1
    o['b'] = 'asdf'

    assert_eq(1, o['a'])
    assert_eq('asdf', o['b'])

    try:
        o['c']
        assert False, 'Should throw key error'
    except KeyError:
        pass
开发者ID:jcheng31,项目名称:3245-homework-4,代码行数:13,代码来源:test_ordered_dict.py


示例12: test_postings_file_write_entry_overwrite

def test_postings_file_write_entry_overwrite():
    filename = 'test'
    with PostingsFile(filename, 'w+') as pfile:
        assert_eq(0, pfile.pointer)
        write_location = 0

        entry = PostingsFileEntry(1)
        entry.own_pointer = write_location

        pfile.write_entry(entry)

        assert_eq(
            PostingsFileEntry(1).to_string(),
            pfile.read_entry(write_location))

        entry.next_pointer = 2
        pfile.write_entry(entry)

        assert_eq(
            PostingsFileEntry(1, 2).to_string(),
            pfile.read_entry(write_location))

        entry.skip_pointer = 3
        pfile.write_entry(entry)

        assert_eq(
            PostingsFileEntry(1, 2, 3).to_string(),
            pfile.read_entry(write_location))

    os.remove(filename)
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:30,代码来源:test_postings_file.py


示例13: test_postings_file_get_entry

def test_postings_file_get_entry():
    filename = 'test'
    with PostingsFile(filename, 'w+') as pfile:
        head = pfile.pointer
        pfile.write_entry(PostingsFileEntry(1))

        # Test that we set the entries own pointer.
        assert_eq(head, pfile.get_entry(head).own_pointer)

        ptr = pfile.pointer
        pfile.write_entry(PostingsFileEntry(2))
        assert_eq(ptr, pfile.get_entry(ptr).own_pointer)

    os.remove(filename)
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:14,代码来源:test_postings_file.py


示例14: test_infix_to_prefix_complex

def test_infix_to_prefix_complex():
    query = 'a AND b OR c'
    assert_eq(['OR', 'AND', 'a', 'b', 'c'], infix_to_prefix(query))

    query = 'a AND NOT b'
    assert_eq(['AND', 'a', 'NOT', 'b'], infix_to_prefix(query))

    query = 'a AND NOT b OR c'
    assert_eq(['OR', 'AND', 'a', 'NOT', 'b', 'c'], infix_to_prefix(query))

    query = 'a AND (NOT b) OR c'
    assert_eq(['OR', 'AND', 'a', 'NOT', 'b', 'c'], infix_to_prefix(query))

    query = 'a AND (b OR NOT c) AND d'
    assert_eq(['AND', 'a', 'AND', 'OR', 'b', 'NOT', 'c', 'd'], infix_to_prefix(query))
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:15,代码来源:test_parse_query.py


示例15: test_postings_file_get_entry_from_pointer

def test_postings_file_get_entry_from_pointer():
    filename = 'test'
    with PostingsFile(filename, 'w+') as pfile:
        head = pfile.pointer
        prev_ptr = head
        pfile.write_entry(1)

        for i in xrange(10):
            next_ptr = pfile.pointer
            pfile.write_entry(i + 1, next_ptr, write_location=prev_ptr)
            pfile.write_entry(i + 2, write_location=next_ptr)
            prev_ptr = next_ptr

        entries = pfile.get_entry_list_from_pointer(head)
        entries = [entry.doc_id for entry in entries]
        assert_eq([1,2,3,4,5,6,7,8,9,10,11], entries)

    os.remove(filename)
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:18,代码来源:test_postings_file.py


示例16: test_ordered_dict_popitem

def test_ordered_dict_popitem():
    o = OrderedDict()
    o['a'] = 1
    o['b'] = 'asdf'

    assert_eq(1, o.popitem(True))
    assert_eq(1, len(o))

    o['a'] = 1
    assert_eq(1, o.popitem())
    assert_eq(1, len(o))
开发者ID:jcheng31,项目名称:3245-homework-4,代码行数:11,代码来源:test_ordered_dict.py


示例17: test_list_node

def test_list_node():
    ln = ListNode.from_list([])
    assert ln is None

    ln = ListNode.from_list([1, 2, 3])
    assert_eq(1, ln.val())
    ln = ln.next()
    assert_eq(2, ln.val())
    ln = ln.next()
    assert_eq(3, ln.val())
    ln = ln.next()
    assert_eq(None, ln)
开发者ID:ymichael,项目名称:cs3245-hw,代码行数:12,代码来源:test_boolean_operations.py


示例18: test_dictionary_all_docs

def test_dictionary_all_docs():
    d = Dictionary()
    assert_eq([], d.all_docs())

    d.add_term('asdf', 1, 1)
    assert_eq([1], d.all_docs())

    d.add_term('asdf', 2, 1)
    assert_eq([1, 2], d.all_docs())

    d.add_term('qwer', 1, 1)
    d.add_term('zxcv', 1, 1)
    assert_eq([1, 2], d.all_docs())
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:13,代码来源:test_dictionary.py


示例19: test_dictionary_all_terms

def test_dictionary_all_terms():
    d = Dictionary()
    assert_eq([], d.all_terms())

    d.add_term('asdf', 1, 1)
    assert_eq(['asdf'], d.all_terms())

    d.add_term('asdf', 2, 1)
    assert_eq(['asdf'], d.all_terms())

    d.add_term('qwer', 1, 1)
    d.add_term('zxcv', 1, 1)
    assert_eq(
        sorted(['asdf', 'qwer', 'zxcv']),
        sorted(d.all_terms()))
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:15,代码来源:test_dictionary.py


示例20: test_infix_to_prefix_single_operator

def test_infix_to_prefix_single_operator():
    query = 'a AND b'
    assert_eq(['AND', 'a', 'b'], infix_to_prefix(query))

    query = 'a OR b'
    assert_eq(['OR', 'a', 'b'], infix_to_prefix(query))

    query = 'NOT b'
    assert_eq(['NOT', 'b'], infix_to_prefix(query))
开发者ID:kaiserahmed,项目名称:cs3245-hw,代码行数:9,代码来源:test_parse_query.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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