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

Python tools.assert_dict_equal函数代码示例

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

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



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

示例1: test_bench_job_3_with_block_size

 def test_bench_job_3_with_block_size(self):
     self.scenario.block_size = 111
     bench_job = self.scenario.bench_job('huge', 3, 30230)
     assert_dict_equal(dict(
         type=ssbench.DELETE_OBJECT,
         size_str='huge',
     ), bench_job)
开发者ID:portante,项目名称:ssbench,代码行数:7,代码来源:test_scenario.py


示例2: test_attribute_1

 def test_attribute_1(self):
     xml = '<attribute name="long_name" ' \
           'value="Specified height level above ground"/>'
     element = ET.fromstring(xml)
     expected = {"long_name": "Specified height level above ground"}
     actual = self.types.handle_attribute(element)
     assert_dict_equal(expected, actual)
开发者ID:scollis,项目名称:siphon,代码行数:7,代码来源:test_ncss_dataset.py


示例3: test_read_from_project_using_filename

    def test_read_from_project_using_filename(self, filename):
        with open(filename, 'r', encoding="utf-8") as doors_file:
            def resource_open(a, b, astext):
                return doors_file

            self.module.read_from_project(resource_open)

        # Very simple verification by checking the amount of different types of doors that were read
        assert_equal(len(self.module.door_areas), 40 * 32)
        num_door_types = dict()
        num_empty_areas = 0
        for area in self.module.door_areas:
            if area is not None and len(area) > 0:
                for door in area:
                    if door.__class__.__name__ not in num_door_types:
                        num_door_types[door.__class__.__name__] = 1
                    else:
                        num_door_types[door.__class__.__name__] += 1
            else:
                num_empty_areas += 1
        assert_equal(num_empty_areas, 679)
        assert_dict_equal(num_door_types, {
            "SwitchDoor": 6,
            "EscalatorOrStairwayDoor": 92,
            "Door": 1072,
            "NpcDoor": 269,
            "RopeOrLadderDoor": 641,
        })
开发者ID:LittleCube13,项目名称:CoilSnake,代码行数:28,代码来源:test_DoorModule.py


示例4: test_node_values

 def test_node_values(self):
     """results.TestrunResult.totals: Tests with subtests values are correct"""
     expect = results.Totals()
     expect['pass'] += 1
     expect['crash'] += 1
     expect['fail'] += 1
     nt.assert_dict_equal(self.test[grouptools.join('sub', 'test')], expect)
开发者ID:Jul13t,项目名称:piglit,代码行数:7,代码来源:results_tests.py


示例5: test_readManifestFile__synapseStore_values_are_set

def test_readManifestFile__synapseStore_values_are_set():

    project_id = "syn123"
    header = 'path\tparent\tsynapseStore\n'
    path1 = os.path.abspath(os.path.expanduser('~/file1.txt'))
    path2 = 'http://www.synapse.org'
    path3 = os.path.abspath(os.path.expanduser('~/file3.txt'))
    path4 = 'http://www.github.com'
    path5 = os.path.abspath(os.path.expanduser('~/file5.txt'))
    path6 = 'http://www.checkoutmymixtapefam.com/fire.mp3'

    row1 = '%s\t%s\tTrue\n' % (path1, project_id)
    row2 = '%s\t%s\tTrue\n' % (path2, project_id)
    row3 = '%s\t%s\tFalse\n' % (path3, project_id)
    row4 = '%s\t%s\tFalse\n' % (path4, project_id)
    row5 = '%s\t%s\t""\n' % (path5, project_id)
    row6 = '%s\t%s\t""\n' % (path6, project_id)

    expected_synapseStore = {
        str(path1): True,
        str(path2): False,
        str(path3): False,
        str(path4): False,
        str(path5): True,
        str(path6): False
    }

    manifest = StringIO(header+row1+row2+row3+row4+row5+row6)
    with patch.object(syn, "get", return_value=Project()),\
         patch.object(os.path, "isfile", return_value=True):  # mocks values for: file1.txt, file3.txt, file5.txt
        manifest_dataframe = synapseutils.sync.readManifestFile(syn, manifest)

        actual_synapseStore = (manifest_dataframe.set_index('path')['synapseStore'].to_dict())
        assert_dict_equal(expected_synapseStore, actual_synapseStore)
开发者ID:Sage-Bionetworks,项目名称:synapsePythonClient,代码行数:34,代码来源:unit_test_synapseutils_sync.py


示例6: test_user_info

    def test_user_info(self):
        client = self.get_client()
        subject = "Joe USER"
        headers = {
            HTTP_HEADER_USER_INFO: subject,
            HTTP_HEADER_SIGNATURE: ""
        }
        t = client.fetch_user_token(headers)

        nt.assert_equal(self.appId, t.validity.issuedTo)
        nt.assert_equal(self.appId, t.validity.issuedFor)
        nt.assert_equal(subject, t.tokenPrincipal.principal)
        nt.assert_equal("Joe User", t.tokenPrincipal.name)
        nt.assert_set_equal({'A', 'B', 'C'}, t.authorizations.formalAuthorizations)
        nt.assert_equal("EzBake", t.organization)
        nt.assert_equal("USA", t.citizenship)
        nt.assert_equal("low", t.authorizationLevel)
        nt.assert_dict_equal(dict([
            ('EzBake', ['Core']),
            ('42six', ['Dev', 'Emp']),
            ('Nothing', ['groups', 'group2'])]), t.externalProjectGroups)
        community_membership = t.externalCommunities['EzBake']
        nt.assert_equal("office", community_membership.type)
        nt.assert_equal("EzBake", community_membership.organization)
        nt.assert_true(community_membership.flags['ACIP'])
        nt.assert_list_equal(['topic1', 'topic2'], community_membership.topics)
        nt.assert_list_equal(['region1', 'region2', 'region3'], community_membership.regions)
        nt.assert_list_equal([], community_membership.groups)
开发者ID:crawlik,项目名称:ezbake-common-python,代码行数:28,代码来源:test_client_2.py


示例7: test_recurse

 def test_recurse(self):
     """results.TestrunResult.totals: Recurses correctly"""
     expected = results.Totals()
     expected['fail'] += 1
     expected['crash'] += 1
     expected['skip'] += 1
     nt.assert_dict_equal(self.test['foo'], expected)
开发者ID:Jul13t,项目名称:piglit,代码行数:7,代码来源:results_tests.py


示例8: check_items_equal

def check_items_equal(actual_value, expected_value, msg=""):
    """
    :param actual_value:
    :param expected_value:
    :param msg:
    :return:

    """
    if isinstance(actual_value, (list, dict, tuple)):
        msg = "\n" + msg + "\n\nDiffering items :\nFirst Argument(Usually Actual) marked with (-)," \
                           "Second Argument(Usually Expected) marked with (+)"
    else:
        msg = "\n" + msg + "\nFirst Argument(Usually Actual), Second Argument(Usually Expected)"

    if not actual_value or not expected_value:
        assert_equal(actual_value, expected_value, u"{}\n{} != {}".format(msg, actual_value, expected_value))

    elif isinstance(actual_value, (list, tuple)):
        assert_items_equal(sorted(actual_value), sorted(expected_value),
                           u"{}\n{}".format(msg, unicode(diff(sorted(actual_value),
                                                          sorted(expected_value)))))
    elif isinstance(actual_value, dict):
        assert_dict_equal(actual_value, expected_value,
                     u"{}\n{}".format(msg, unicode(diff(actual_value, dict(expected_value)))))
    elif isinstance(actual_value, (str, bool)):
        assert_equal(actual_value, expected_value,
                     u"{}\n{} != {}".format(msg, unicode(actual_value), unicode(expected_value)))
    else:
        assert_equal(actual_value, expected_value,
                     u"{}\n{} != {}".format(msg, actual_value, expected_value))
开发者ID:dudycooly,项目名称:python_helpers,代码行数:30,代码来源:asserter.py


示例9: test_empty_ns_in_consul

def test_empty_ns_in_consul():
    fn = 'test_empty_ns_in_consul'
    check_call('consulconf -i %s -p %s/test-%s --delete'
               % (CWD, AGENT, fn), shell=True)
    nt.assert_dict_equal(
        json.loads(check_output(
            'consulconf -i %s/test-%s --dry_run' % (AGENT, fn), shell=True)
            .decode()),
        {
            "test": {},
            "test-namespace": {},
            "test-ns1": {"key1": "val1"},
            "test-ns2": {"key1": "val1"},
            "test/app1": {},
            "test/app2": {"key1": "val1"},
            "test/app20": {"key": "value"},
            "test/app21": {"key": "value", "key1": "val1"},
            "test/app22": {"key1": "val1"},
            "test/app3": {},
            "test/app4": {"key2": "val2"},
            "test/app5": {"key1": "val1", "key2": "val2"},
            "test/app6": {"key1": "val11"},
            "test/app7": {"key1": "val11", "key2": "val2"},
            "test/app8": {"key1": "val1", "key2": "val22"},
            "test/app9": {"key1": "val1", "key2": "val222"}
        }

    )
开发者ID:sailthru,项目名称:consulconf,代码行数:28,代码来源:test_integration.py


示例10: test_multiline_fields_nosplit

    def test_multiline_fields_nosplit(self):
        f = StringIO(preamble_s + "PT abc\nSC Here; there\n  be dragons; Yes"
                     "\nER\nEF")

        r = PlainTextReader(f)
        expected = {"PT": "abc", "SC": "Here; there be dragons; Yes"}
        assert_dict_equal(next(r), expected)
开发者ID:niutyut,项目名称:wos,代码行数:7,代码来源:test_read.py


示例11: test_one_record

    def test_one_record(self):
        f = StringIO("PT\tAF\tC1\nJ\tAa; Bb\tX; Y")

        r = TabDelimitedReader(f)
        expected = {"PT": "J", "AF": "Aa; Bb", "C1": "X; Y"}

        assert_dict_equal(next(r), expected)
开发者ID:niutyut,项目名称:wos,代码行数:7,代码来源:test_read.py


示例12: test_cache

def test_cache():
    scheme = 'https'
    gotten = set()
    def get(url):
        raise AssertionError('This should not run.')
    n_threads = 4

    search_url = 'https://chicago.craigslist.org/sub/index000.html'
    listing_url = 'https://chicago.craigslist.org/sub/42832238.html'
    warehouse = {
        (search_url,fake_datetime.date().isoformat()):fake_response(search_url),
        listing_url:fake_response(listing_url),
    }
    site = 'chicago.craigslist.org'
    section = 'sub'

    parse_listing = lambda response: {'html':response.text,'foo':'bar'}
    parse_search = lambda response: [{'href':listing_url, 'date': None}]

    searched = set()
    def parse_next_search_url(scheme, site, section, html):
        if html == None:
            searched.clear()
        url = '%s://%s/%s/index%d00.html' % (scheme, site, section, len(searched))
        searched.add(url)
        return url

    l = listings(scheme, get, n_threads, warehouse, site, section,
                 parse_listing, parse_search, parse_next_search_url,
                 fake_download, lambda: fake_datetime)
    n.assert_dict_equal(next(l), fake_result(listing_url))
开发者ID:abelsonlive,项目名称:craigsgenerator,代码行数:31,代码来源:test_listings.py


示例13: test_specified_file_does_not_exist

    def test_specified_file_does_not_exist(self):
        def fail_to_open(foo):
            open('/a/b/c/d', 'r')
 
        observed = app.redirect_must_exist(fail_to_open)('elephant')
        expected = { "error": "That redirect doesn't exist. Use PUT to create it." }
        n.assert_dict_equal(observed, expected)
开发者ID:tlevine,项目名称:redirect.thomaslevine.com,代码行数:7,代码来源:unittests.py


示例14: check_flatten

def check_flatten(tests, testlist):
    """ TestProfile.prepare_test_list flattens TestProfile.tests """
    profile_ = profile.TestProfile()
    profile_.tests = tests
    profile_._flatten_group_hierarchy()

    nt.assert_dict_equal(profile_.test_list, testlist)
开发者ID:ThirteenFish,项目名称:piglit,代码行数:7,代码来源:profile_tests.py


示例15: test_score

    def test_score(
            self,
            _score_ratio_mock,
            _score_special_mock,
            _score_numbers_mock,
            _score_case_mock,
            _score_length_mock):

        _score_ratio_mock.return_value = 2
        _score_special_mock.return_value = 3
        _score_numbers_mock.return_value = 5
        _score_case_mock.return_value = 7
        _score_length_mock.return_value = 11

        expected_result = {
            'length': 11,
            'case': 7,
            'numbers': 5,
            'special': 3,
            'ratio': 2,
            'total': 28,
        }

        validator = PasswordValidator('')

        assert_dict_equal(expected_result, validator.score())
开发者ID:eflittle,项目名称:learningpython,代码行数:26,代码来源:test_passwords.py


示例16: test_getitem

def test_getitem():
    fields = ModelDataFields()
    fields.new_field_location('node', 12)

    assert_dict_equal(dict(), fields['node'])
    assert_raises(GroupError, lambda k: fields[k], 'cell')
    assert_raises(KeyError, lambda k: fields[k], 'cell')
开发者ID:Carralex,项目名称:landlab,代码行数:7,代码来源:test_graph_fields.py


示例17: _check_fixture

def _check_fixture(name):
    "Check a cgitrepos file in the fixtures directory."
    cgitrepos = open(os.path.join('fixtures', name))
    cgitrepos_json = open(os.path.join('fixtures', name + '.json'))

    # Check that the cgitrepos file matches the JSON.
    try:
        observed = _parse(cgitrepos.read())
    except:
        # Such a hack
        observed = {}

    expected = json.loads(cgitrepos_json.read())
    cgitrepos.close()
    cgitrepos_json.close()

    if type(expected) != dict:
        # Point out that the JSON file is bad.
        assert False, 'The test is malformed; the file %s must be a dict at its root.'

    elif type(observed) != dict:
        # Point out that the JSON file is bad.
        assert False, 'The parser returned a type other than dict.'

    else:
        # Test each associative array (repository).
        for name in expected:
            n.assert_in(name, observed)
            n.assert_dict_equal(observed[name], expected[name])
开发者ID:tlevine,项目名称:cgitrepos,代码行数:29,代码来源:test.py


示例18: test_load_dictionary

    def test_load_dictionary(self):
        c = self.comp
        d = c.as_dictionary(True)
        n = Component(self.parameter_names)

        n._id_name = 'dummy names yay!'
        _ = n._load_dictionary(d)
        nt.assert_equal(c.name, n.name)
        nt.assert_equal(c.active, n.active)
        nt.assert_equal(
            c.active_is_multidimensional,
            n.active_is_multidimensional)

        for pn, pc in zip(n.parameters, c.parameters):
            rn = np.random.random()
            nt.assert_equal(pn.twin_function(rn), pc.twin_function(rn))
            nt.assert_equal(
                pn.twin_inverse_function(rn),
                pc.twin_inverse_function(rn))
            dn = pn.as_dictionary()
            del dn['self']
            del dn['twin_function']
            del dn['twin_inverse_function']
            dc = pc.as_dictionary()
            del dc['self']
            del dc['twin_function']
            del dc['twin_inverse_function']
            print(list(dn.keys()))
            print(list(dc.keys()))
            nt.assert_dict_equal(dn, dc)
开发者ID:AakashV,项目名称:hyperspy,代码行数:30,代码来源:test_model_as_dictionary.py


示例19: test_error_from_cadasta_api_raises_validation_error

    def test_error_from_cadasta_api_raises_validation_error(self):
        for action, cadasta_endpoint in get_api_map.items():
            print "testing {action}".format(action=action),

            # add the expected parameters (everything is a 1)
            api_url = cadasta_endpoint.url
            url_args = dict([(a[1], 1) for a in string.Formatter().parse(api_url) if a[1]])

            # make sure the point parameters are filled out
            endpoint = urljoin(self.test_api, api_url).format(**url_args)

            # fake out our response
            responses.add(
                responses.GET,
                endpoint,
                body='{"error": {"code": 1}, "message": "err msg"}',
                content_type="application/json",
            )

            with assert_raises(toolkit.ValidationError) as cm:
                helpers.call_action(action, **url_args)

            assert_dict_equal({u"code": [1], "message": [u"err msg"], "type": [""]}, cm.exception.error_dict)

            print "\t[OK]"
开发者ID:Cadasta,项目名称:ckanext-project,代码行数:25,代码来源:test_api.py


示例20: dict_eq

def dict_eq(one, two):
    """Assert two dict-like objects are equal.

    Casts to dict, and then uses nose.tools.assert_dict_equal.

    """
    nt.assert_dict_equal(dict(one), dict(two))
开发者ID:BNieuwenhuizen,项目名称:piglit,代码行数:7,代码来源:results_tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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