本文整理汇总了Python中nose.tools.assert_dict_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_dict_equal函数的具体用法?Python assert_dict_equal怎么用?Python assert_dict_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_dict_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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,
})
示例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)
示例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)
示例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)
示例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)
示例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))
示例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"}
}
)
示例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)
示例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)
示例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))
示例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)
示例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)
示例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())