當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。