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

Python six.assertCountEqual函数代码示例

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

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



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

示例1: test_write_genre_list

    def test_write_genre_list(self):
        mediafile = self._mediafile_fixture('empty')
        mediafile.genres = [u'one', u'two']
        mediafile.save()

        mediafile = MediaFile(mediafile.path)
        assertCountEqual(self, mediafile.genres, [u'one', u'two'])
开发者ID:Kraymer,项目名称:beets,代码行数:7,代码来源:test_mediafile.py


示例2: test_with_binary_media_types

    def test_with_binary_media_types(self):

        template = {
            "Resources": {

                "Api1": {
                    "Type": "AWS::Serverless::Api",
                    "Properties": {
                        "StageName": "Prod",
                        "DefinitionBody": make_swagger(self.input_apis, binary_media_types=self.binary_types)
                    }
                }
            }
        }

        expected_binary_types = sorted(self.binary_types)
        expected_apis = [
            Api(path="/path1", method="GET", function_name="SamFunc1", cors=None,
                binary_media_types=expected_binary_types),
            Api(path="/path1", method="POST", function_name="SamFunc1", cors=None,
                binary_media_types=expected_binary_types),

            Api(path="/path2", method="PUT", function_name="SamFunc1", cors=None,
                binary_media_types=expected_binary_types),
            Api(path="/path2", method="GET", function_name="SamFunc1", cors=None,
                binary_media_types=expected_binary_types),

            Api(path="/path3", method="DELETE", function_name="SamFunc1", cors=None,
                binary_media_types=expected_binary_types)
        ]

        provider = SamApiProvider(template)
        assertCountEqual(self, expected_apis, provider.apis)
开发者ID:Frameio,项目名称:aws-sam-cli,代码行数:33,代码来源:test_sam_api_provider.py


示例3: test_must_prefer_implicit_api_over_explicit

    def test_must_prefer_implicit_api_over_explicit(self):

        implicit_apis = {
            "Event1": {
                "Type": "Api",
                "Properties": {
                    # This API is duplicated between implicit & explicit
                    "Path": "/path1",
                    "Method": "get"
                }
            },

            "Event2": {
                "Type": "Api",
                "Properties": {
                    "Path": "/path2",
                    "Method": "POST"
                }
            }
        }

        self.template["Resources"]["Api1"]["Properties"]["DefinitionBody"] = self.swagger
        self.template["Resources"]["ImplicitFunc"]["Properties"]["Events"] = implicit_apis

        expected_apis = [
            Api(path="/path1", method="GET", function_name="ImplicitFunc", cors=None),  # Comes from Implicit

            Api(path="/path2", method="GET", function_name="explicitfunction", cors=None),
            Api(path="/path2", method="POST", function_name="ImplicitFunc", cors=None),  # Comes from implicit

            Api(path="/path3", method="GET", function_name="explicitfunction", cors=None),
        ]

        provider = SamApiProvider(self.template)
        assertCountEqual(self, expected_apis, provider.apis)
开发者ID:Frameio,项目名称:aws-sam-cli,代码行数:35,代码来源:test_sam_api_provider.py


示例4: test_fit_and_transform

    def test_fit_and_transform(self):
        augmenter = FeatureAugmenter(column_value="val", column_id="id", column_sort="sort",
                                     column_kind="kind",
                                     kind_to_fc_parameters=self.kind_to_fc_parameters)

        # Fit should do nothing
        returned_df = augmenter.fit()
        six.assertCountEqual(self, returned_df.__dict__, augmenter.__dict__)
        self.assertRaises(RuntimeError, augmenter.transform, None)

        augmenter.set_timeseries_container(self.test_df)

        # Add features to all time series
        X_with_index = pd.DataFrame([{"feature_1": 1}]*2, index=[10, 500])
        X_transformed = augmenter.transform(X_with_index)

        # Require same shape
        for i in X_transformed.index:
            self.assertIn(i, X_with_index.index)

        for i in X_with_index.index:
            self.assertIn(i, X_transformed.index)

        self.assertEqual(X_transformed.shape, (2, 3))

        # Preserve old features
        six.assertCountEqual(self, list(X_transformed.columns), ["feature_1", "a__length", "b__length"])

        # Features are not allowed to be NaN
        for index, row in X_transformed.iterrows():
            print((index, row))
            self.assertFalse(np.isnan(row["a__length"]))
            self.assertFalse(np.isnan(row["b__length"]))
开发者ID:carrielui,项目名称:tsfresh,代码行数:33,代码来源:test_feature_augmenter.py


示例5: test_with_swagger_as_both_body_and_uri

    def test_with_swagger_as_both_body_and_uri(self, SamSwaggerReaderMock):

        body = {"some": "body"}
        filename = "somefile.txt"

        template = {
            "Resources": {

                "Api1": {
                    "Type": "AWS::Serverless::Api",
                    "Properties": {
                        "StageName": "Prod",
                        "DefinitionUri": filename,
                        "DefinitionBody": body
                    }
                }
            }
        }

        SamSwaggerReaderMock.return_value.read.return_value = make_swagger(self.input_apis)

        cwd = "foo"
        provider = SamApiProvider(template, cwd=cwd)
        assertCountEqual(self, self.input_apis, provider.apis)
        SamSwaggerReaderMock.assert_called_with(definition_body=body, definition_uri=filename, working_dir=cwd)
开发者ID:Frameio,项目名称:aws-sam-cli,代码行数:25,代码来源:test_sam_api_provider.py


示例6: test_get_multiple_albums_by_id

    def test_get_multiple_albums_by_id(self):
        response = self.client.get('/album/1,2')
        response.json = json.loads(response.data.decode('utf-8'))

        self.assertEqual(response.status_code, 200)
        response_albums = [album['album'] for album in response.json['albums']]
        assertCountEqual(self, response_albums, [u'album', u'another album'])
开发者ID:Jashpal-mahida,项目名称:beets,代码行数:7,代码来源:test_web.py


示例7: test_delete_stacks_uses_the_correct_order

    def test_delete_stacks_uses_the_correct_order(self,
                                                  custom_resource_mock,
                                                  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):
            if args[2] == 'a':
                return stack_a
            if args[2] == '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)
开发者ID:gvsurenderreddy,项目名称:cfn-sphere,代码行数:28,代码来源:stack_action_handler_tests.py


示例8: test_group

 def test_group(self):
     assign_perm("view_collection", self.group1, self.collection)
     assign_perm("edit_collection", self.group1, self.collection)
     user_perms, group_perms = get_user_group_perms(self.group1, self.collection)
     self.assertEqual(len(group_perms), 1)
     six.assertCountEqual(self, group_perms[0][2], ["view_collection", "edit_collection"])
     self.assertEqual(len(user_perms), 0)
开发者ID:jkokosar,项目名称:resolwe,代码行数:7,代码来源:test_shortcuts.py


示例9: test_numeric_range_filter

    def test_numeric_range_filter(self):
        # https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html

        numeric_range_filter_options = {
            "fields": ["start", "end", "age"],
            "field_validators": {
                "start": ["date"],
                "end": ["date"],
            }
        }

        filter = filters.NumericRangeFilter

        query_params = {'start.gte': '2016-01-01', 'start.lte': '2001-06-01', 'start.tz': 'Pacific/Auckland', 'age.gt': '18'}

        queryset = self.get_queryset_for_filter(filter=filter, query_params=query_params,
                                                options=numeric_range_filter_options)

        self.assertEqual(len(queryset.filters), 2)
        self.assertEqual(len(queryset.queries), 0)

        # raw
        six.assertCountEqual(self, queryset.filters,[
            ('range', {'start': {'gte': '2016-01-01', 'lte': '2001-06-01', 'time_zone': 'Pacific/Auckland'}}),
            ('range', {'age': {'gt': '18'}})
                             ])
开发者ID:predicthq,项目名称:rfhq,代码行数:26,代码来源:elasticsearch_filter_tests.py


示例10: test_search_with_nodes_and_duplicate_label

    def test_search_with_nodes_and_duplicate_label(self):
        self.fake_authentication()

        response = self.client.get(
                '/%d/search' % self.test_project_id,
                {'substring': 'uncertain end'})
        self.assertEqual(response.status_code, 200)
        parsed_response = json.loads(response.content.decode('utf-8'))

        # Expect only one result that has a node linked
        expected_result = [
            {"id":2342, "name":"uncertain end", "class_name":"label", "nodes":[
                {"id":403, "x":7840, "y":2380, "z":0, "skid":373}]},
        ]
        six.assertCountEqual(self, expected_result, parsed_response)

        # Add a duplicate record of the label, without any node links
        label = ClassInstance.objects.get(id=2342)
        label.id = None
        label.save()

        response2 = self.client.get(
                '/%d/search' % self.test_project_id,
                {'substring': 'uncertain end'})
        self.assertEqual(response2.status_code, 200)
        parsed_response2 = json.loads(response2.content.decode(('utf-8')))

        # Expect the nodes to be not linked to the duplicate record
        expected_result2 = [
            {"id":label.id, "name":"uncertain end", "class_name":"label"},
            {"id":2342, "name":"uncertain end", "class_name":"label", "nodes":[
                {"id":403, "x":7840, "y":2380, "z":0, "skid":373}]}
        ]
        six.assertCountEqual(self, expected_result2, parsed_response2)
开发者ID:tomka,项目名称:CATMAID,代码行数:34,代码来源:test_search.py


示例11: test_parse_stream

    def test_parse_stream(
        self, structure_and_messages1, structure_and_messages2, structure_and_messages3
    ):
        """
        L{Parser.parse_stream} returns an iterable of completed and then
        incompleted tasks.
        """
        _, messages1 = structure_and_messages1
        _, messages2 = structure_and_messages2
        _, messages3 = structure_and_messages3
        # Need at least one non-dropped message in partial tree:
        assume(len(messages3) > 1)
        # Need unique UUIDs per task:
        assume(
            len(set(m[0][TASK_UUID_FIELD] for m in (messages1, messages2, messages3)))
            == 3
        )

        # Two complete tasks, one incomplete task:
        all_messages = (messages1, messages2, messages3[:-1])

        all_tasks = list(
            Parser.parse_stream(
                [m for m in chain(*zip_longest(*all_messages)) if m is not None]
            )
        )
        assertCountEqual(
            self, all_tasks, [parse_to_task(msgs) for msgs in all_messages]
        )
开发者ID:ClusterHQ,项目名称:eliot,代码行数:29,代码来源:test_parse.py


示例12: assertSearchResults

    def assertSearchResults(self, results=None, resultCode=0):
        """
        Shortcut for checking results returned by test server on LDAPSearchRequest.
        Results must be prepared as a list of dictionaries with 'objectName' and 'attributes' keys
        """
        if results is None:
            results = []

        messages = []

        for result in results:
            message = pureldap.LDAPMessage(
                pureldap.LDAPSearchResultEntry(
                    objectName=result['objectName'],
                    attributes=result['attributes']
                ),
                id=2
            )
            messages.append(message)

        messages.append(
            pureldap.LDAPMessage(
                pureldap.LDAPSearchResultDone(resultCode=resultCode),
                id=2
            )
        )
        six.assertCountEqual(
            self,
            self._makeResultList(self.server.transport.value()),
            [msg.toWire() for msg in messages]
        )
开发者ID:GrayAn,项目名称:ldaptor,代码行数:31,代码来源:test_server.py


示例13: test_uniform_noise_4_bots_no_noise_manhattan

    def test_uniform_noise_4_bots_no_noise_manhattan(self):
        test_layout = (
        """ ##################
            # #.  .  # . 2   #
            # #####    #####3#
            #  0  . #  .  .#1#
            ################## """)
        universe = CTFUniverse.create(test_layout, 4)
        noiser = ManhattanNoiser(universe.copy())

        expected_0 = [ (1, 1), (3, 1), (4, 1), (5, 1), (6, 1),
                       (1, 2), (1, 3), (2, 3), (3, 3), (4, 3), (5, 3),
                       (6, 3), (7, 3), (7, 2) ]
        position_bucket_0 = collections.defaultdict(int)

        bot_2_pos = (13, 1)
        position_bucket_2 = {bot_2_pos : 0}

        for i in range(200):
            new = noiser.uniform_noise(universe.copy(), 1)
            self.assertTrue(new.bots[0].noisy)
            self.assertFalse(new.bots[2].noisy)
            position_bucket_0[new.bots[0].current_pos] += 1
            position_bucket_2[new.bots[2].current_pos] += 1
        self.assertEqual(200, sum(position_bucket_0.values()))
        self.assertEqual(200, sum(position_bucket_2.values()))
        # Since this is a randomized algorithm we need to be a bit lenient with
        # our tests. We check that each position was selected at least once.
        six.assertCountEqual(self, position_bucket_0, expected_0, position_bucket_0)

        # bots should never have been noised
        self.assertEqual(200, position_bucket_2[bot_2_pos])
开发者ID:NelleV,项目名称:pelita,代码行数:32,代码来源:test_game_master.py


示例14: test_uniform_noise_4_bots_a_star

    def test_uniform_noise_4_bots_a_star(self):
        test_layout = (
        """ ##################
            # #. 2.  # .     #
            # #####    #####3#
            #  0  . #  .  .#1#
            ################## """)
        universe = CTFUniverse.create(test_layout, 4)
        noiser = AStarNoiser(universe.copy())

        expected_0 = [(1, 2), (7, 3), (1, 3), (3, 3), (6, 3),
                      (2, 3), (4, 3), (1, 1), (5, 3)]
        position_bucket_0 = collections.defaultdict(int)

        expected_2 = [(7, 3), (8, 2), (7, 1), (8, 1), (6, 1), (3, 1), (5, 1),
                      (4, 1), (7, 2)]
        position_bucket_2 = collections.defaultdict(int)

        for i in range(100):
            new = noiser.uniform_noise(universe.copy(), 1)
            self.assertTrue(new.bots[0].noisy)
            self.assertTrue(new.bots[2].noisy)
            position_bucket_0[new.bots[0].current_pos] += 1
            position_bucket_2[new.bots[2].current_pos] += 1
        self.assertEqual(100, sum(position_bucket_0.values()))
        self.assertEqual(100, sum(position_bucket_2.values()))
        # Since this is a randomized algorithm we need to be a bit lenient with
        # our tests. We check that each position was selected at least once.
        six.assertCountEqual(self, position_bucket_0, expected_0, sorted(position_bucket_0.keys()))
        six.assertCountEqual(self, position_bucket_2, expected_2, sorted(position_bucket_2.keys()))
开发者ID:NelleV,项目名称:pelita,代码行数:30,代码来源:test_game_master.py


示例15: test_many_elements

 def test_many_elements(self):
     expected_data = []
     for i in range(20):
         self.d.add(i, i)
         expected_data.append((i, i))
     gevent.sleep(TestFlushingDict.FLUSH_LATENCY_SECONDS + 0.1)
     six.assertCountEqual(self, expected_data, sum(self.received_data, []))
开发者ID:Nyrio,项目名称:cms,代码行数:7,代码来源:flushingdict_test.py


示例16: testTracking

 def testTracking(self):
   model = HasList()
   output = model(array_ops.ones([32, 2]))
   self.assertAllEqual([32, 12], output.shape)
   self.assertEqual(11, len(model.layers))
   self.assertEqual(10, len(model.layer_list.layers))
   six.assertCountEqual(
       self,
       model.layers,
       model.layer_list.layers + model.layers_with_updates)
   for index in range(10):
     self.assertEqual(3 + index, model.layer_list.layers[index].units)
   self.assertEqual(2, len(model._checkpoint_dependencies))
   self.assertIs(model.layer_list, model._checkpoint_dependencies[0].ref)
   self.assertIs(model.layers_with_updates,
                 model._checkpoint_dependencies[1].ref)
   self.assertEqual(
       10, len(model._checkpoint_dependencies[0].ref._checkpoint_dependencies))
   self.evaluate([v.initializer for v in model.variables])
   self.evaluate(model.variables[0].assign([[1., 2., 3.], [4., 5., 6.]]))
   save_path = os.path.join(self.get_temp_dir(), "ckpt")
   model.save_weights(save_path)
   self.evaluate(model.variables[0].assign(array_ops.zeros([2, 3])))
   model.load_weights(save_path)
   self.assertAllEqual([[1., 2., 3.], [4., 5., 6.]],
                       self.evaluate(model.variables[0]))
   v = variables.Variable(1.)
   model.var_list = [v]
   self.assertIn(v, model.variables)
   self.assertIn(v, model.trainable_variables)
   self.assertNotIn(v, model.non_trainable_variables)
开发者ID:AnishShah,项目名称:tensorflow,代码行数:31,代码来源:data_structures_test.py


示例17: test_transform_dict_to_yaml_lines_list_accepts_joins

    def test_transform_dict_to_yaml_lines_list_accepts_joins(self):
        input = {
            "source": {"Fn::Join": [":", ["my-registry/my-app", {"Ref": "appVersion"}]]}
        }

        expected = [
            {
                "Fn::Join": [
                    ": ",
                    [
                        "source",
                        {
                            "Fn::Join": [
                                ":",
                                [
                                    "my-registry/my-app",
                                    {
                                        "Ref": "appVersion"
                                    }
                                ]
                            ]
                        }
                    ]
                ]
            }
        ]

        result = CloudFormationTemplateTransformer.transform_dict_to_yaml_lines_list(input)
        six.assertCountEqual(self, expected, result)
开发者ID:oliver-schoenherr,项目名称:cfn-sphere,代码行数:29,代码来源:transformer_tests.py


示例18: test_that_workspace_property_returns_workspace_when_not_in_ADS

    def test_that_workspace_property_returns_workspace_when_not_in_ADS(self):
        workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace)

        ws_property = workspace_handle.workspace

        six.assertCountEqual(self, ws_property.readX(0), [1, 2, 3, 4])
        six.assertCountEqual(self, ws_property.readY(0), [10, 10, 10, 10])
开发者ID:samueljackson92,项目名称:mantid,代码行数:7,代码来源:muon_workspace_wrapper_test.py


示例19: test_finalize_stats_summaries

 def test_finalize_stats_summaries(self):
   p = plan.Plan(None)
   p.save_summaries_secs = 42
   p.losses['foo'] = tf.constant([1.0])
   p.losses['bar'] = tf.constant([2.0, 3.0])
   p.metrics['baz'] = tf.constant(4)
   p.metrics['qux'] = tf.constant([5.0, 6.0])
   p.finalize_stats()
   with self.test_session():
     self.assertEqual(6, p.loss_total.eval({p.batch_size_placeholder: 1}))
     summary = tf.Summary()
     summary.ParseFromString(p.summaries.eval({p.batch_size_placeholder: 1}))
     qux_string = tf.summary.histogram('qux', [5, 6]).eval()
     qux_proto = tf.Summary()
     qux_proto.ParseFromString(qux_string)
     qux_histogram = qux_proto.value[0].histo
     expected_values = [
         tf.Summary.Value(tag='foo', simple_value=1),
         tf.Summary.Value(tag='bar', simple_value=5),
         tf.Summary.Value(tag='loss_total', simple_value=6),
         tf.Summary.Value(tag='baz', simple_value=4),
         tf.Summary.Value(tag='qux', histo=qux_histogram)]
     six.assertCountEqual(self, expected_values, summary.value)
     summary.ParseFromString(p.summaries.eval({p.batch_size_placeholder: 2}))
     expected_values = [
         tf.Summary.Value(tag='foo', simple_value=0.5),
         tf.Summary.Value(tag='bar', simple_value=2.5),
         tf.Summary.Value(tag='loss_total', simple_value=3),
         tf.Summary.Value(tag='baz', simple_value=4),
         tf.Summary.Value(tag='qux', histo=qux_histogram)]
     six.assertCountEqual(self, expected_values, summary.value)
开发者ID:wangbosdqd,项目名称:fold,代码行数:31,代码来源:plan_test.py


示例20: testExample

  def testExample(self):
    class SlotManager(tracking.AutoCheckpointable):

      def __init__(self):
        self.slotdeps = containers.UniqueNameTracker()
        slotdeps = self.slotdeps
        slots = []
        slots.append(slotdeps.track(
            resource_variable_ops.ResourceVariable(3.), "x"))
        slots.append(slotdeps.track(
            resource_variable_ops.ResourceVariable(4.), "y"))
        slots.append(slotdeps.track(
            resource_variable_ops.ResourceVariable(5.), "x"))
        self.slots = data_structures.NoDependency(slots)

    manager = SlotManager()
    self.evaluate([v.initializer for v in manager.slots])
    checkpoint = util.Checkpoint(slot_manager=manager)
    checkpoint_directory = self.get_temp_dir()
    checkpoint_prefix = os.path.join(checkpoint_directory, "ckpt")
    save_path = checkpoint.save(checkpoint_prefix)
    metadata = util.object_metadata(save_path)
    dependency_names = []
    for node in metadata.nodes:
      for child in node.children:
        dependency_names.append(child.local_name)
    six.assertCountEqual(
        self,
        dependency_names,
        ["x", "x_1", "y", "slot_manager", "slotdeps", "save_counter"])
开发者ID:AndreasGocht,项目名称:tensorflow,代码行数:30,代码来源:containers_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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