Python nose.tools.eq_() Examples
The following are 30
code examples of nose.tools.eq_().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
nose.tools
, or try the search function
.
Example #1
Source File: multi_process_test.py From dispel4py with Apache License 2.0 | 6 votes |
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])
Example #2
Source File: multi_process_test.py From dispel4py with Apache License 2.0 | 6 votes |
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))
Example #3
Source File: multi_process_test.py From dispel4py with Apache License 2.0 | 6 votes |
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))
Example #4
Source File: simple_process_test.py From dispel4py with Apache License 2.0 | 6 votes |
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)
Example #5
Source File: simple_process_test.py From dispel4py with Apache License 2.0 | 6 votes |
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)
Example #6
Source File: processor_test.py From dispel4py with Apache License 2.0 | 6 votes |
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))
Example #7
Source File: test_sctp.py From ryu with Apache License 2.0 | 6 votes |
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:])
Example #8
Source File: simple_process_test.py From dispel4py with Apache License 2.0 | 6 votes |
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)
Example #9
Source File: test_variant_collection.py From varcode with Apache License 2.0 | 6 votes |
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)
Example #10
Source File: multi_process_test.py From dispel4py with Apache License 2.0 | 6 votes |
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))
Example #11
Source File: processor_test.py From dispel4py with Apache License 2.0 | 6 votes |
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)
Example #12
Source File: multi_process_test.py From dispel4py with Apache License 2.0 | 6 votes |
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)
Example #13
Source File: shingles_tests.py From locality-sensitive-hashing with MIT License | 6 votes |
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)
Example #14
Source File: shingles_tests.py From locality-sensitive-hashing with MIT License | 6 votes |
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)
Example #15
Source File: test_sctp.py From ryu with Apache License 2.0 | 5 votes |
def test_serialize_with_heartbeat_ack(self): self.setUp_with_heartbeat_ack() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_heartbeat_ack._PACK_STR, buf) eq_(sctp.chunk_heartbeat_ack.chunk_type(), res[0]) eq_(self.flags, res[1]) eq_(self.length, res[2]) buf = buf[sctp.chunk_heartbeat_ack._MIN_LEN:] res1 = struct.unpack_from(sctp.param_heartbeat._PACK_STR, buf) eq_(sctp.param_heartbeat.param_type(), res1[0]) eq_(12, res1[1]) eq_(b'\xff\xee\xdd\xcc\xbb\xaa\x99\x88', buf[sctp.param_heartbeat._MIN_LEN: sctp.param_heartbeat._MIN_LEN + 8])
Example #16
Source File: test_variant_collection.py From varcode with Apache License 2.0 | 5 votes |
def test_variant_collection_intersection(): combined = ov_wustle_variants.intersection(tcga_ov_variants) eq_(set(combined.sources), {ov_wustle_variants.source, tcga_ov_variants.source}) eq_(len(combined), 0)
Example #17
Source File: test_sctp.py From ryu with Apache License 2.0 | 5 votes |
def test_init(self): eq_(self.src_port, self.sc.src_port) eq_(self.dst_port, self.sc.dst_port) eq_(self.vtag, self.sc.vtag) eq_(self.csum, self.sc.csum) eq_(self.chunks, self.sc.chunks)
Example #18
Source File: test_sctp.py From ryu with Apache License 2.0 | 5 votes |
def test_parser(self): _res = self.sc.parser(six.binary_type(self.buf)) if type(_res) is tuple: res = _res[0] else: res = _res # to calculate the lengths of parameters. self.sc.serialize(None, None) eq_(self.src_port, res.src_port) eq_(self.dst_port, res.dst_port) eq_(self.vtag, res.vtag) eq_(self.csum, res.csum) eq_(str(self.chunks), str(res.chunks))
Example #19
Source File: test_sctp.py From ryu with Apache License 2.0 | 5 votes |
def _test_serialize(self): buf = self.sc.serialize(bytearray(), None) res = struct.unpack_from(sctp.sctp._PACK_STR, buf) eq_(self.src_port, res[0]) eq_(self.dst_port, res[1]) eq_(self.vtag, res[2]) # skip compare checksum # eq_(self.csum, res[3]) return buf[sctp.sctp._MIN_LEN:]
Example #20
Source File: test_sctp.py From ryu with Apache License 2.0 | 5 votes |
def test_serialize_with_heartbeat(self): self.setUp_with_heartbeat() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_heartbeat._PACK_STR, buf) eq_(sctp.chunk_heartbeat.chunk_type(), res[0]) eq_(self.flags, res[1]) eq_(self.length, res[2]) buf = buf[sctp.chunk_heartbeat._MIN_LEN:] res1 = struct.unpack_from(sctp.param_heartbeat._PACK_STR, buf) eq_(sctp.param_heartbeat.param_type(), res1[0]) eq_(8, res1[1]) eq_(b'\x01\x02\x03\x04', buf[sctp.param_heartbeat._MIN_LEN: sctp.param_heartbeat._MIN_LEN + 4])
Example #21
Source File: test_sctp.py From ryu with Apache License 2.0 | 5 votes |
def test_serialize_with_shutdown_ack(self): self.setUp_with_shutdown_ack() buf = self._test_serialize() res = struct.unpack_from(sctp.chunk_shutdown_ack._PACK_STR, buf) eq_(sctp.chunk_shutdown_ack.chunk_type(), res[0]) eq_(self.flags, res[1]) eq_(self.length, res[2])
Example #22
Source File: test_variant_collection.py From varcode with Apache License 2.0 | 5 votes |
def test_variant_collection_gene_counts(): gene_counts = ov_wustle_variants.gene_counts() # test that each gene is counted just once eq_(list(gene_counts.values()), [1] * len(gene_counts))
Example #23
Source File: test_variant_collection.py From varcode with Apache License 2.0 | 5 votes |
def test_reference_names(): eq_(ov_wustle_variants.reference_names(), {"GRCh37"})
Example #24
Source File: test_variant_collection.py From varcode with Apache License 2.0 | 5 votes |
def test_variant_collection_union(): combined = ov_wustle_variants.union(tcga_ov_variants) eq_(set(combined.sources), {ov_wustle_variants.source, tcga_ov_variants.source}) eq_(len(combined), len(ov_wustle_variants) + len(tcga_ov_variants))
Example #25
Source File: test.py From deepWordBug with Apache License 2.0 | 5 votes |
def eq(self, a, b, msg=None): """Shorthand for 'assert a == b, "%r != %r" % (a, b)'. """ return eq(a, b, msg) # The following are for internal, Cement unit testing only
Example #26
Source File: workflow_graph_test.py From dispel4py with Apache License 2.0 | 5 votes |
def test_types(): graph = WorkflowGraph() prod = TestProducer() cons = TestOneInOneOut() graph.connect(prod, 'output', cons, 'input') graph.propagate_types() tools.eq_(prod.outputconnections['output']['type'], cons.inputconnections['input']['type'])
Example #27
Source File: simple_process_test.py From dispel4py with Apache License 2.0 | 5 votes |
def testComposite(): comp = CompositePE() cons1 = TestOneInOneOut() cons2 = TestOneInOneOut() comp.connect(cons1, 'output', cons2, 'input') 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}) tools.eq_({cons.id: {'output': list(range(1, 11))}}, results)
Example #28
Source File: simple_process_test.py From dispel4py with Apache License 2.0 | 5 votes |
def testConsumer(): graph = WorkflowGraph() prod = TestProducer() cons = PrintDataConsumer() graph.connect(prod, 'output', cons, 'input') results = simple_process.process_and_return(graph, {prod: 10}) tools.eq_({}, results)
Example #29
Source File: simple_process_test.py From dispel4py with Apache License 2.0 | 5 votes |
def testProducer(): graph = WorkflowGraph() prod = IntegerProducer(5, 234) cons = TestIterative() graph.connect(prod, 'output', cons, 'input') results = simple_process.process_and_return(graph, {prod: 1}) tools.eq_({cons.id: {'output': list(range(5, 234))}}, results)
Example #30
Source File: simple_process_test.py From dispel4py with Apache License 2.0 | 5 votes |
def testWriter(): graph = WorkflowGraph() prod = TestProducer() cons1 = TestOneInOneOutWriter() graph.connect(prod, 'output', cons1, 'input') results = simple_process.process_and_return(graph, {prod: 5}) tools.eq_({cons1.id: {'output': list(range(1, 6))}}, results)