Python six.assertCountEqual() Examples
The following are 30
code examples of six.assertCountEqual().
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
six
, or try the search function
.
Example #1
Source File: pubsub_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_list_topics(self): """Test listing topics.""" expected = [] for i in range(5): topic = pubsub.topic_name(PROJECT_NAME, 'topic-{}'.format(i)) expected.append(topic) self.client.create_topic(topic) expected.append('projects/fake-project/topics/test-topic') topics = list(self.client.list_topics('projects/' + PROJECT_NAME)) six.assertCountEqual(self, expected, topics) # Note: Page size appears to be ignored by the emulator. Even when creating # large amounts of topics to force paging, the nextPageToken returned is # buggy and results in infinite loops. topics = list( self.client.list_topics('projects/' + PROJECT_NAME, page_size=1)) six.assertCountEqual(self, expected, topics)
Example #2
Source File: issue_filer_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_component_add_label(self): """Test that we set labels for component builds.""" self.testcase.job_type = 'job' self.testcase.impact_stable_version = 'Stable' self.testcase.impact_beta_version = 'Beta' self.testcase.put() data_types.Job( name='job', environment_string=( 'RELEASE_BUILD_BUCKET_PATH = ' 'https://example.com/blah-v8-component-([0-9]+).zip\n')).put() self.testcase.is_impact_set_flag = True mock_issue = self._make_mock_issue() issue_filer.update_issue_impact_labels(self.testcase, mock_issue) six.assertCountEqual(self, ['Security_Impact-Stable'], mock_issue.labels.added) six.assertCountEqual(self, [], mock_issue.labels.removed)
Example #3
Source File: graph_test.py From paleo with Apache License 2.0 | 6 votes |
def test_dependency2(self): two_towers = """{ "name" : "test", "layers" : { "data": { "parents": [] }, "conv1": { "parents": ["data"] }, "output": { "parents" : ["data", "conv1"] } } } """ self.graph.load_from_string(two_towers) nested_list = self._to_strings(self.graph.nested_list) self.assertEqual(nested_list[0], 'data') six.assertCountEqual(self, nested_list[1], (['conv1'], )) self.assertEqual(nested_list[2], 'output')
Example #4
Source File: graph_test.py From paleo with Apache License 2.0 | 6 votes |
def test_dependency(self): two_towers = """{ "name" : "test", "layers" : { "data": { "parents": [] }, "conv1": { "parents": ["data"] }, "conv2": { "parents": ["data"] }, "output": { "parents" : ["conv1", "conv2"] } } } """ self.graph.load_from_string(two_towers) nested_list = self._to_strings(self.graph.nested_list) self.assertEqual(nested_list[0], 'data') six.assertCountEqual(self, nested_list[1], (['conv1'], ['conv2'])) self.assertEqual(nested_list[2], 'output')
Example #5
Source File: untrusted_runner_integration_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_corpus_sync(self): """Test syncing corpus.""" environment.set_value('CORPUS_BUCKET', 'clusterfuzz-test-data') corpus = corpus_manager.RemoteFuzzTargetCorpus('corpus_test_fuzzer', 'child_fuzzer') worker_root = environment.get_value('WORKER_ROOT_DIR') test_corpus_directory = os.path.join(worker_root, 'corpus') os.mkdir(test_corpus_directory) try: self.assertTrue(corpus.rsync_to_disk(test_corpus_directory)) six.assertCountEqual(self, os.listdir(test_corpus_directory), ['123', '456', 'abc']) finally: if os.path.exists(test_corpus_directory): shutil.rmtree(test_corpus_directory, ignore_errors=True)
Example #6
Source File: untrusted_runner_integration_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_list_files(self): """Tests remote list_files.""" fuzz_inputs = file_host.rebase_to_worker_root(os.environ['FUZZ_INPUTS']) with open(os.path.join(fuzz_inputs, 'a'), 'w') as f: f.write('') with open(os.path.join(fuzz_inputs, 'b'), 'w') as f: f.write('') os.mkdir(os.path.join(fuzz_inputs, 'c')) with open(os.path.join(fuzz_inputs, 'c', 'c'), 'w') as f: f.write('') six.assertCountEqual(self, [ os.path.join(fuzz_inputs, 'a'), os.path.join(fuzz_inputs, 'b'), os.path.join(fuzz_inputs, 'c'), ], file_host.list_files(fuzz_inputs)) six.assertCountEqual(self, [ os.path.join(fuzz_inputs, 'a'), os.path.join(fuzz_inputs, 'b'), os.path.join(fuzz_inputs, 'c', 'c'), ], file_host.list_files(fuzz_inputs, recursive=True))
Example #7
Source File: cleanup_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_only_add_five_random_ccs(self): """Test that up to 5 random ccs are added. """ issue_owners = ['dev%s@example.com' % idx for idx in range(100)] self.testcase.set_metadata('issue_owners', ','.join(issue_owners)) helpers.patch(self, ['random.sample']) self.mock.sample.side_effect = lambda l, size: l[-size:] cleanup.update_issue_ccs_from_owners_file(self.policy, self.testcase, self.issue) self.assertEqual( 'Automatically adding ccs based on OWNERS file / target commit history.' '\n\nIf this is incorrect, please add the ClusterFuzz-Wrong label.', self.issue._monorail_issue.comment) six.assertCountEqual(self, issue_owners[-5:], self.issue.ccs) self.assertIn('ClusterFuzz-Auto-CC', self.issue.labels)
Example #8
Source File: issue_tracker_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_add_and_remove(self): """Test both adding and removing.""" store = LabelStore(['laBel1', 'label2', 'Label3']) store.remove('Label1') six.assertCountEqual(self, ['label2', 'Label3'], store) six.assertCountEqual(self, [], store.added) six.assertCountEqual(self, ['Label1'], store.removed) store.add('label1') six.assertCountEqual(self, ['label1', 'label2', 'Label3'], store) six.assertCountEqual(self, [], store.added) six.assertCountEqual(self, [], store.removed) store.remove('Label1') store.add('label4') six.assertCountEqual(self, ['label2', 'Label3', 'label4'], store) six.assertCountEqual(self, ['label4'], store.added) six.assertCountEqual(self, ['Label1'], store.removed)
Example #9
Source File: issue_tracker_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_add(self): """Test adding items.""" store = LabelStore() store.add('laBel1') six.assertCountEqual(self, ['laBel1'], store) six.assertCountEqual(self, ['laBel1'], store.added) six.assertCountEqual(self, [], store.removed) store.add('label2') six.assertCountEqual(self, ['laBel1', 'label2'], store) six.assertCountEqual(self, ['laBel1', 'label2'], store.added) six.assertCountEqual(self, [], store.removed) store.add('labEl2') six.assertCountEqual(self, ['laBel1', 'labEl2'], store) six.assertCountEqual(self, ['laBel1', 'labEl2'], store.added) six.assertCountEqual(self, [], store.removed)
Example #10
Source File: issue_tracker_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_remove(self): """Test removing items.""" store = LabelStore(['laBel1', 'label2', 'Label3']) store.remove('Label1') six.assertCountEqual(self, ['label2', 'Label3'], store) six.assertCountEqual(self, [], store.added) six.assertCountEqual(self, ['Label1'], store.removed) store.remove('Label2') six.assertCountEqual(self, ['Label3'], store) six.assertCountEqual(self, [], store.added) six.assertCountEqual(self, ['Label1', 'Label2'], store.removed) store.remove('LaBel2') six.assertCountEqual(self, ['Label3'], store) six.assertCountEqual(self, [], store.added) six.assertCountEqual(self, ['Label1', 'Label2'], store.removed) store.remove('Label4') six.assertCountEqual(self, ['Label3'], store) six.assertCountEqual(self, [], store.added) six.assertCountEqual(self, ['Label1', 'Label2'], store.removed)
Example #11
Source File: engine_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_prepare(self): """Test prepare.""" engine_impl = engine.LibFuzzerEngine() options = engine_impl.prepare('/corpus_dir', '/path/target', '/path') self.assertEqual('/corpus_dir', options.corpus_dir) six.assertCountEqual(self, [ '-max_len=31337', '-timeout=11', '-rss_limit_mb=2560', '-arg1', '-dict=/path/blah.dict' ], options.arguments) self.assertDictEqual({ 'value_profile': 1, 'corpus_subset': 20, 'fork': 2 }, options.strategies) six.assertCountEqual(self, ['/new_corpus_dir', '/corpus_dir'], options.fuzz_corpus_dirs) self.assertDictEqual({'extra_env': '1'}, options.extra_env) self.assertFalse(options.use_dataflow_tracing) self.assertTrue(options.is_mutations_run) self.mock.unpack_seed_corpus_if_needed.assert_called_with( '/path/target', '/corpus_dir')
Example #12
Source File: corpus_pruning_task_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_prune(self): """Basic pruning test.""" self.corpus_dir = self.fuchsia_corpus_dir corpus_pruning_task.execute_task( 'libFuzzer_fuchsia_example-fuzzers-trap_fuzzer', 'libfuzzer_asan_fuchsia') corpus = os.listdir(self.corpus_dir) self.assertEqual(2, len(corpus)) six.assertCountEqual(self, [ '801c34269f74ed383fc97de33604b8a905adb635', '7cf184f4c67ad58283ecb19349720b0cae756829' ], corpus) quarantine = os.listdir(self.quarantine_dir) self.assertEqual(1, len(quarantine)) six.assertCountEqual( self, ['crash-7a8dc3985d2a90fb6e62e94910fc11d31949c348'], quarantine)
Example #13
Source File: corpus_pruning_task_test.py From clusterfuzz with Apache License 2.0 | 6 votes |
def test_get_libfuzzer_flags(self): """Test get_libfuzzer_flags logic.""" fuzz_target = data_handler.get_fuzz_target('libFuzzer_test_fuzzer') context = corpus_pruning_task.Context( fuzz_target, [], corpus_pruning_task.Pollination.RANDOM, None) runner = corpus_pruning_task.Runner(self.build_dir, context) flags = runner.get_libfuzzer_flags() expected_default_flags = [ '-timeout=5', '-rss_limit_mb=2560', '-max_len=5242880', '-detect_leaks=1', '-use_value_profile=1' ] six.assertCountEqual(self, flags, expected_default_flags) runner.fuzzer_options = options.FuzzerOptions( os.path.join(self.build_dir, 'test_get_libfuzzer_flags.options')) flags = runner.get_libfuzzer_flags() expected_custom_flags = [ '-timeout=5', '-rss_limit_mb=2560', '-max_len=1337', '-detect_leaks=0', '-use_value_profile=1' ] six.assertCountEqual(self, flags, expected_custom_flags)
Example #14
Source File: test_databases_bigg.py From ssbio with MIT License | 5 votes |
def test_get_pdbs_for_gene(self): model = 'e_coli_core' gene = 'b0118' expected = [('1l5j', 'A'), ('1l5j', 'B')] six.assertCountEqual(self, expected, ssbio.databases.bigg.get_pdbs_for_gene(model, gene, force_rerun=True)) model = 'e_coli_core' gene = 'b0351' expected = [] six.assertCountEqual(self, expected, ssbio.databases.bigg.get_pdbs_for_gene(model, gene, force_rerun=True))
Example #15
Source File: test_keras.py From coremltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_dense(self): """ Test the conversion of Dense layer. """ from keras.layers import Dense # Create a simple Keras model model = Sequential() model.add(Dense(32, input_dim=16)) input_names = ["input"] output_names = ["output"] spec = keras.convert(model, input_names, output_names).get_spec() self.assertIsNotNone(spec) # Test the model class self.assertIsNotNone(spec.description) self.assertTrue(spec.HasField("neuralNetwork")) # Test the inputs and outputs self.assertEquals(len(spec.description.input), len(input_names)) six.assertCountEqual( self, input_names, [x.name for x in spec.description.input] ) self.assertEquals(len(spec.description.output), len(output_names)) six.assertCountEqual( self, output_names, [x.name for x in spec.description.output] ) # Test the layer parameters. layers = spec.neuralNetwork.layers layer_0 = layers[0] self.assertIsNotNone(layer_0.innerProduct)
Example #16
Source File: nse_tests.py From nsetools with MIT License | 5 votes |
def test_get_stock_codes(self): sc = self.nse.get_stock_codes() self.assertIsNotNone(sc) self.assertIsInstance(sc, dict) # test the json format return sc_json = self.nse.get_stock_codes(as_json=True) self.assertIsInstance(sc_json, str) # reconstruct the dict from json and compare six.assertCountEqual(self, sc, json.loads(sc_json)) # TODO: use mock and create one test where response contains a blank line # TODO: use mock and create one test where response doesnt contain a csv # TODO: use mock and create one test where return is null # TODO: test the cache feature
Example #17
Source File: cloudformation_template_tests.py From cfn-sphere with Apache License 2.0 | 5 votes |
def test_get_no_echo_parameter_keys_returns_parameter_keys_with_no_echo_set(self): template_body = { 'Parameters': { 'myParameter1': { 'Type': 'String', 'NoEcho': True }, 'myParameter2': { 'Type': 'String' }, 'myParameter3': { 'Type': 'Number', 'NoEcho': 'true' }, 'myParameter4': { 'Type': 'Number', 'NoEcho': 'false' }, 'myParameter5': { 'Type': 'Number', 'NoEcho': False } } } template = CloudFormationTemplate(template_body, 'some name') six.assertCountEqual(self, ['myParameter1', 'myParameter3'], template.get_no_echo_parameter_keys())
Example #18
Source File: stack_action_handler_tests.py From cfn-sphere with Apache License 2.0 | 5 votes |
def test_delete_stacks_uses_the_correct_order(self, stack_mock, template_loader_mock, dependency_resolver_mock, parameter_resolver_mock, cfn_mock): dependency_resolver_mock.return_value.get_stack_order.return_value = ['a', 'c'] cfn_mock.return_value.get_stack_names.return_value = ['a', 'c'] stack_a = CloudFormationStack('', [], 'a', '') stack_c = CloudFormationStack('', [], 'c', '') def stack_side_effect(*args, **kwargs): if kwargs["name"] == 'a': return stack_a if kwargs["name"] == 'c': return stack_c return None stack_mock.side_effect = stack_side_effect handler = StackActionHandler(Mock()) handler.delete_stacks() expected_calls = [call(stack_c), call(stack_a)] six.assertCountEqual(self, expected_calls, cfn_mock.return_value.delete_stack.mock_calls)
Example #19
Source File: test_parser.py From monasca-analytics with Apache License 2.0 | 5 votes |
def test_parse_save_as(self): info = parser.get_parser().parseString("sAVE(/root/0/path_/f.conf)") self.assertEqual(1, len(info)) six.assertCountEqual(self, [const.SAVE_AS], info[0].keys()) self.assert_save_as(info[0], "/root/0/path_/f.conf")
Example #20
Source File: test_parser.py From monasca-analytics with Apache License 2.0 | 5 votes |
def test_parse_save(self): info = parser.get_parser().parseString("sAVe()") self.assertEqual(1, len(info)) six.assertCountEqual(self, [const.SAVE], info[0].keys()) self.assert_save(info[0])
Example #21
Source File: cloudformation_template_tests.py From cfn-sphere with Apache License 2.0 | 5 votes |
def test_get_no_echo_parameter_keys_returns_empty_list_without_parameters(self): template_body = { 'Parameters': {} } template = CloudFormationTemplate(template_body, 'some name') six.assertCountEqual(self, [], template.get_no_echo_parameter_keys())
Example #22
Source File: test_common_util.py From monasca-analytics with Apache License 2.0 | 5 votes |
def test_parse_json_file(self): current_dir = os.path.dirname(__file__) test_json_file = os.path.join(current_dir, "../resources/test_json.json") parsed_json = common_util.parse_json_file(test_json_file) six.assertCountEqual(self, parsed_json["sources"]["src1"], {"module": "src_module1", "params": { "param1": "val1", "param2": "val2", "model_id": 3} }) six.assertCountEqual(self, parsed_json["ingestors"]["ing1"], {"module": "ingestor_module"}) six.assertCountEqual(self, parsed_json["smls"]["sml1"], {"module": "sml_module"}) self.assertEqual(parsed_json["voters"]["vot1"], {"module": "voter_module"}) six.assertCountEqual(self, parsed_json["sinks"]["snk1"], {"module": "sink_module1"}) six.assertCountEqual(self, parsed_json["sinks"]["snk2"], {"module": "sink_module2"}) six.assertCountEqual(self, parsed_json["ldps"]["ldp1"], {"module": "ldps_module1"}) six.assertCountEqual(self, parsed_json["connections"], {"src1": ["ing1"], "src2": ["ing1"], "ing1": ["aggr1", "ldp1", "sin1"], "snk1": [], "snk2": [], "sml1": ["vot1", "snk1"], "vot1": ["ldp1", "snk1"], "ldp1": ["snk2"]}) six.assertCountEqual(self, parsed_json["feedback"], {"snk1": ["sml1"], "snk2": ["vot1"]})
Example #23
Source File: graph_test.py From paleo with Apache License 2.0 | 5 votes |
def test_model_parallel(self): two_towers = """{ "name" : "test", "layers" : { "data": { "parents": [] }, "conv1": { "parents": ["data"] }, "conv2": { "type": "ModelParallel", "parents": ["conv1"], "splits": 2, "layers": { "conv2a": { "parents": [] }, "mix": { "parents": ["conv2a@all"] } } }, "output": { "parents" : ["conv2/mix@all"] } } } """ self.graph.load_from_string(two_towers) nested_list = self._to_strings(self.graph.nested_list) self.assertEqual(nested_list[0], 'data') self.assertEqual(nested_list[1], 'conv1') six.assertCountEqual(self, nested_list[2], (['conv2/conv2a@0'], ['conv2/conv2a@1'])) six.assertCountEqual(self, nested_list[3], (['conv2/mix@0'], ['conv2/mix@1'])) self.assertEqual(nested_list[4], 'output')
Example #24
Source File: test_common_util.py From monasca-analytics with Apache License 2.0 | 5 votes |
def test_get_available_ingestor_class_names(self): names = common_util.get_available_ingestor_class_names() six.assertCountEqual( self, ['CloudIngestor', 'IptablesIngestor'], names)
Example #25
Source File: graph_test.py From paleo with Apache License 2.0 | 5 votes |
def test_block(self): two_towers = """{ "name" : "test", "layers" : { "data": { "parents": [] }, "conv1": { "parents": ["data"] }, "conv2": { "type": "Block", "parents": ["conv1"], "endpoint": "concat", "layers": { "conv2a": { "parents": [] }, "conv2b" : { "parents": [] }, "concat": { "parents": ["conv2a", "conv2b"] } } }, "output": { "parents" : ["conv2"] } } } """ self.graph.load_from_string(two_towers) nested_list = self._to_strings(self.graph.nested_list) self.assertEqual(nested_list[0], 'data') self.assertEqual(nested_list[1], 'conv1') six.assertCountEqual(self, nested_list[2], (['conv2/conv2a'], ['conv2/conv2b'])) self.assertEqual(nested_list[3], 'conv2/concat') self.assertEqual(nested_list[4], 'output')
Example #26
Source File: builtin_fuzzers_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
def test_generate_blackbox_fuzzers(self): """Test generate_blackbox_fuzzers (success).""" output = ('metadata::fuzzer_binary_name: fuzzer_binary_name\n') self.mock.run.side_effect = functools.partial(_mock_fuzzer_run, output, 4, 'corpus_dir') self.assertTrue(setup.update_fuzzer_and_data_bundles('libFuzzer')) session = fuzz_task.FuzzingSession('libFuzzer', 'job', 1) session.testcase_directory = '/output' session.data_directory = '/input' (error_occurred, testcase_file_paths, sync_corpus_directory, fuzzer_metadata) = session.generate_blackbox_testcases( self.fuzzer, self.fuzzer_directory, 4) self.assertEqual(1, len(self.mock.run.call_args_list)) self.assertEqual(('/input', '/output', 4), self.mock.run.call_args[0][1:]) self.assertFalse(error_occurred) six.assertCountEqual(self, [ '/output/fuzz-0', '/output/fuzz-1', '/output/fuzz-2', '/output/fuzz-3', ], testcase_file_paths) self.assertEqual('corpus_dir', sync_corpus_directory) self.assertDictEqual({ 'fuzzer_binary_name': 'fuzzer_binary_name' }, fuzzer_metadata)
Example #27
Source File: untrusted_runner_integration_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
def test_setup_testcase(self): """Test setup_testcase.""" job_type = 'job' self._setup_env(job_type=job_type) fuzz_inputs = os.environ['FUZZ_INPUTS'] testcase = data_types.Testcase() testcase.job_type = job_type testcase.absolute_path = os.path.join(fuzz_inputs, 'testcase.ext') with tempfile.NamedTemporaryFile() as f: f.write(b'contents') f.seek(0) testcase.fuzzed_keys = blobs.write_blob(f) testcase.put() file_list, input_directory, testcase_file_path = ( setup.setup_testcase(testcase, job_type)) six.assertCountEqual(self, file_list, [ testcase.absolute_path, ]) self.assertEqual(input_directory, fuzz_inputs) self.assertEqual(testcase_file_path, testcase.absolute_path) worker_fuzz_inputs = file_host.rebase_to_worker_root(fuzz_inputs) self.assert_dirs_equal(fuzz_inputs, worker_fuzz_inputs)
Example #28
Source File: engine_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
def test_max_length_strategy_without_override(self): """Tests max length strategy without override.""" self.mock.randint.return_value = 1337 strategy_pool = set_strategy_pool([strategy.RANDOM_MAX_LENGTH_STRATEGY]) strategy_info = libfuzzer.pick_strategies(strategy_pool, '/path/target', '/path/corpus', []) six.assertCountEqual(self, ['-max_len=1337'], strategy_info.arguments)
Example #29
Source File: engine_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
def test_max_length_strategy_with_override(self): """Tests max length strategy with override.""" strategy_pool = set_strategy_pool([strategy.RANDOM_MAX_LENGTH_STRATEGY]) strategy_info = libfuzzer.pick_strategies(strategy_pool, '/path/target', '/path/corpus', ['-max_len=100']) six.assertCountEqual(self, [], strategy_info.arguments)
Example #30
Source File: engine_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
def test_prepare_invalid_dict(self): """Test prepare with an invalid dict path.""" with open('/path/target.options', 'w') as f: f.write('[libfuzzer]\n' 'max_len=31337\n' 'timeout=11\n' 'dict=not_exist.dict\n') engine_impl = engine.LibFuzzerEngine() options = engine_impl.prepare('/corpus_dir', '/path/target', '/path') six.assertCountEqual( self, ['-max_len=31337', '-timeout=11', '-rss_limit_mb=2560', '-arg1'], options.arguments)