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


Python tools.eq_方法代码示例

本文整理汇总了Python中nose.tools.eq_方法的典型用法代码示例。如果您正苦于以下问题:Python tools.eq_方法的具体用法?Python tools.eq_怎么用?Python tools.eq_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nose.tools的用法示例。


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

示例1: test_shingle_generator_k_shingles_yield_list_of_strings

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def test_shingle_generator_k_shingles_yield_list_of_strings(mock_k_shingles_gen):
    # set up
    type = ShingleType.K_SHINGLES
    size = 4

    faux_results = get_faux_list_of_k_shingles()
    faux_string_generator = generator_string()

    mock_k_shingles_gen.return_value = yield faux_results

    # execute
    actual_results = next(shgl.shingle_generator(faux_string_generator, size=size, type=type))

    # asserts
    mock_k_shingles_gen.assert_called_once_with(faux_string_generator, size)
    nt.eq_(actual_results, faux_results) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:18,代码来源:shingles_tests.py

示例2: test_shingle_generator_w_shingles_yield_list_of_tuples

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def test_shingle_generator_w_shingles_yield_list_of_tuples(mock_w_shingles_gen):
     # set up
    type = ShingleType.W_SHINGLES
    size = 4

    faux_results = get_faux_list_of_w_shingles()
    faux_word_generator = generator_words()

    mock_w_shingles_gen.return_value = yield faux_results

    # execute
    actual_results = next(shgl.shingle_generator(faux_word_generator, size=size, type=type))

    # asserts
    mock_w_shingles_gen.assert_called_once_with(faux_word_generator, size)
    nt.eq_(actual_results, faux_results) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:18,代码来源:shingles_tests.py

示例3: testPipeline

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def testPipeline():
    prod = TestProducer()
    cons1 = TestOneInOneOut()
    cons2 = TestOneInOneOut()
    graph = WorkflowGraph()
    graph.connect(prod, 'output', cons1, 'input')
    graph.connect(cons1, 'output', cons2, 'input')
    args = argparse.Namespace
    args.num = 4
    args.simple = False
    args.results = True
    result_queue = process(graph, inputs={prod: 5}, args=args)
    results = []
    item = result_queue.get()
    while item != STATUS_TERMINATED:
        name, output, data = item
        tools.eq_(cons2.id, name)
        tools.eq_('output', output)
        results.append(data)
        item = result_queue.get()
    tools.eq_(list(range(1, 6)), results) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:23,代码来源:multi_process_test.py

示例4: testSquare

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def testSquare():
    graph = WorkflowGraph()
    prod = TestProducer(2)
    cons1 = TestOneInOneOut()
    cons2 = TestOneInOneOut()
    last = TestTwoInOneOut()
    graph.connect(prod, 'output0', cons1, 'input')
    graph.connect(prod, 'output1', cons2, 'input')
    graph.connect(cons1, 'output', last, 'input0')
    graph.connect(cons2, 'output', last, 'input1')
    args.num = 4
    args.results = True
    result_queue = process(graph, inputs={prod: 10}, args=args)
    results = []
    item = result_queue.get()
    while item != STATUS_TERMINATED:
        name, output, data = item
        tools.eq_(last.id, name)
        tools.eq_('output', output)
        results.append(data)
        item = result_queue.get()
    expected = {str(i): 2 for i in range(1, 11)}
    tools.eq_(expected, Counter(results)) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:25,代码来源:multi_process_test.py

示例5: testTee

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def testTee():
    graph = WorkflowGraph()
    prod = TestProducer()
    cons1 = TestOneInOneOut()
    cons2 = TestOneInOneOut()
    graph.connect(prod, 'output', cons1, 'input')
    graph.connect(prod, 'output', cons2, 'input')
    args.num = 3
    args.results = True
    result_queue = process(graph, inputs={prod: 5}, args=args)
    results = defaultdict(list)
    item = result_queue.get()
    while item != STATUS_TERMINATED:
        name, output, data = item
        tools.eq_('output', output)
        results[name].append(data)
        item = result_queue.get()
    tools.eq_(list(range(1, 6)), results[cons1.id])
    tools.eq_(list(range(1, 6)), results[cons2.id]) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:21,代码来源:multi_process_test.py

示例6: testPipelineSimple

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def testPipelineSimple():
    prod = TestProducer()
    cons1 = TestOneInOneOut()
    cons2 = TestOneInOneOut()
    graph = WorkflowGraph()
    graph.connect(prod, 'output', cons1, 'input')
    graph.connect(cons1, 'output', cons2, 'input')
    args = argparse.Namespace
    args.num = 4
    args.simple = True
    args.results = True
    result_queue = process(graph, inputs={prod: 5}, args=args)
    results = []
    item = result_queue.get()
    while item != STATUS_TERMINATED:
        name, output, data = item
        tools.eq_((cons2.id, 'output'), output)
        results.extend(data)
        item = result_queue.get()
    tools.eq_(Counter(range(1, 6)), Counter(results)) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:22,代码来源:multi_process_test.py

示例7: testPipelineNotEnoughProcesses

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def testPipelineNotEnoughProcesses():
    prod = TestProducer()
    cons1 = TestOneInOneOut()
    cons2 = TestOneInOneOut()
    cons3 = TestOneInOneOut()
    cons4 = TestOneInOneOut()
    graph = WorkflowGraph()
    graph.connect(prod, 'output', cons1, 'input')
    graph.connect(cons1, 'output', cons2, 'input')
    graph.connect(cons2, 'output', cons3, 'input')
    graph.connect(cons3, 'output', cons4, 'input')
    args = argparse.Namespace
    args.num = 4
    args.simple = False
    args.results = True
    result_queue = process(graph, inputs={prod: 10}, args=args)
    results = []
    item = result_queue.get()
    while item != STATUS_TERMINATED:
        name, output, data = item
        tools.eq_((cons4.id, 'output'), output)
        results.extend(data)
        item = result_queue.get()
    tools.eq_(Counter(range(1, 11)), Counter(results)) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:26,代码来源:multi_process_test.py

示例8: test_roots

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def test_roots():
    graph = WorkflowGraph()
    prod1 = TestProducer()
    prod2 = TestProducer()
    cons = TestTwoInOneOut()
    graph.connect(prod1, 'output', cons, 'input1')
    graph.connect(prod2, 'output', cons, 'input2')
    roots = set()
    non_roots = set()
    for node in graph.graph.nodes():
        if node.getContainedObject() == cons:
            non_roots.add(node)
        else:
            roots.add(node)
    for r in roots:
        tools.ok_(p._is_root(r, graph))
    for n in non_roots:
        tools.eq_(False, p._is_root(n, graph)) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:20,代码来源:processor_test.py

示例9: test_input_file

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def test_input_file():
    args = argparse.Namespace
    import tempfile
    namedfile = tempfile.NamedTemporaryFile()
    with namedfile as temp:
        data = '{ "TestProducer": 20}'
        try:
            temp.write(data)
        except:
            temp.write(bytes(data, 'UTF-8'))
        temp.flush()
        temp.seek(0)
        args.file = namedfile.name
        args.data = None
        args.iter = 1
        graph = WorkflowGraph()
        prod = TestProducer()
        graph.add(prod)
        inputs = p.create_inputs(args, graph)
        tools.eq_(inputs[prod.id], 20) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:22,代码来源:processor_test.py

示例10: testInputsAndOutputs

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def testInputsAndOutputs():
    graph = WorkflowGraph()
    prod = TestProducer()
    cons = TestOneInOneOut()
    cons._add_output('output', tuple_type=['integer'])
    cons._add_input('input', grouping=[0], tuple_type=['integer'])
    cons.setInputTypes({'input': ['number']})
    tools.eq_({'output': ['number']}, cons.getOutputTypes())
    cons._add_output('output2')
    try:
        cons.getOutputTypes()
    except Exception:
        pass
    graph.connect(prod, 'output', cons, 'input')
    results = simple_process.process_and_return(graph, {prod: 10})
    tools.eq_({cons.id: {'output': list(range(1, 11))}}, results) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:18,代码来源:simple_process_test.py

示例11: testCreateChain

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def testCreateChain():

    def add(a, b):
        return a + b

    def mult(a, b):
        return a * b

    def is_odd(a):
        return a % 2 == 1

    c = [(add, {'b': 1}), (mult, {'b': 3}), is_odd]
    chain = create_iterative_chain(c)
    prod = TestProducer()
    graph = WorkflowGraph()
    graph.connect(prod, 'output', chain, 'input')
    graph.flatten()
    results = simple_process.process_and_return(graph, {prod: 2})
    for key, value in results.items():
        tools.eq_({'output': [False, True]}, value) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:22,代码来源:simple_process_test.py

示例12: testCompositeWithCreateParams

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def testCompositeWithCreateParams():
    cons1 = TestOneInOneOut()
    cons2 = TestOneInOneOut()

    def create_graph(graph, connections):
        for i in range(connections):
            graph.connect(cons1, 'output', cons2, 'input')

    comp = CompositePE(create_graph, {'connections': 2})
    comp._map_input('comp_input', cons1, 'input')
    comp._map_output('comp_output', cons2, 'output')
    prod = TestProducer()
    cons = TestOneInOneOut()
    graph = WorkflowGraph()
    graph.connect(prod, 'output', comp, 'comp_input')
    graph.connect(comp, 'comp_output', cons, 'input')
    graph.flatten()
    results = simple_process.process_and_return(graph, {prod: 10})
    expected = []
    for i in range(1, 11):
        expected += [i, i]
    tools.eq_({cons.id: {'output': expected}}, results) 
开发者ID:dispel4py,项目名称:dispel4py,代码行数:24,代码来源:simple_process_test.py

示例13: test_gene_counts

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def test_gene_counts():
    expected_coding_gene_counts = Counter()
    expected_coding_gene_counts["CDK11A"] = 1
    expected_coding_gene_counts["GNPAT"] = 1
    expected_coding_gene_counts["E2F2"] = 1
    expected_coding_gene_counts["VSIG2"] = 1
    all_gene_counts = tcga_ov_variants.gene_counts()
    assert len(all_gene_counts) > len(expected_coding_gene_counts), \
        ("Gene counts for all genes must contain more elements than"
         " gene counts for only coding genes.")
    for (gene_name, count) in expected_coding_gene_counts.items():
        eq_(count, all_gene_counts[gene_name])

    # TODO: add `only_coding` parameter to gene_counts and then test
    # for exact equality between `coding_gene_counts` and
    # `expected_counts`
    #
    # coding_gene_counts = variants.gene_counts(only_coding=True)
    # eq_(coding_gene_counts, expected_counts) 
开发者ID:openvax,项目名称:varcode,代码行数:21,代码来源:test_variant_collection.py

示例14: test_serialize_with_data

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def test_serialize_with_data(self):
        self.setUp_with_data()
        buf = self._test_serialize()
        res = struct.unpack_from(sctp.chunk_data._PACK_STR, buf)
        eq_(sctp.chunk_data.chunk_type(), res[0])
        flags = (
            (self.unordered << 2) |
            (self.begin << 1) |
            (self.end << 0))
        eq_(flags, res[1])
        eq_(self.length, res[2])
        eq_(self.tsn, res[3])
        eq_(self.sid, res[4])
        eq_(self.seq, res[5])
        eq_(self.payload_id, res[6])
        eq_(self.payload_data, buf[sctp.chunk_data._MIN_LEN:]) 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:18,代码来源:test_sctp.py

示例15: test_enqueue_add_one_item

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import eq_ [as 别名]
def test_enqueue_add_one_item():
    # set up
    faux_queue = FIFOQueue.instance()
    expected_results = "test_item"

    # execute
    faux_queue.enqueue("test_item")

    # asserts
    nt.eq_(faux_queue.size(), 1)

    actual_result = faux_queue.dequeue()
    nt.eq_(actual_result, expected_results) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:15,代码来源:fifo_queue_tests.py


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