本文整理汇总了Python中unittest.TestCase.assertDictEqual方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.assertDictEqual方法的具体用法?Python TestCase.assertDictEqual怎么用?Python TestCase.assertDictEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestCase
的用法示例。
在下文中一共展示了TestCase.assertDictEqual方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertDictEqual [as 别名]
def compare(self, a, b):
a = json.loads(a)
b = json.loads(b)
t = TestCase()
t.maxDiff = None
try:
self.ttx += 1
t.assertDictEqual(a, b)
except AssertionError as e:
self.ptx += 1
print('[{} / {}] compared {} : FAILURE'.format(self.ptx, self.ttx, a['txid']))
示例2: log_dir_is_correct_for_each_phase
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertDictEqual [as 别名]
def log_dir_is_correct_for_each_phase(recordings: dict,
put: unittest.TestCase,
actual: Result):
put.assertFalse(actual.partial_result.is_failure)
sds = actual.sds
expected = {
PhaseEnum.SETUP: sds_log_phase_dir(sds, phase_identifier.SETUP.identifier),
PhaseEnum.BEFORE_ASSERT: sds_log_phase_dir(sds, phase_identifier.BEFORE_ASSERT.identifier),
PhaseEnum.ASSERT: sds_log_phase_dir(sds, phase_identifier.ASSERT.identifier),
PhaseEnum.CLEANUP: sds_log_phase_dir(sds, phase_identifier.CLEANUP.identifier),
}
put.assertDictEqual(expected,
recordings,
'Log directory per phase')
示例3: compare_properties
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertDictEqual [as 别名]
def compare_properties(self, schema):
"""Compares two schemas. The schema used to call the method
will be the one we compare from, in advance 'source schema'.
The schema passed as parameter will be the 'target schema'.
Returns -- dictionary {status, correct, missing, distinct, message}
being:
status 'OK' if all properties in source schema exist in target
schema with same values. 'KO' in other case.
correct: list of properties that matches.
missing: list of properties missing from target schema.
distinct: list of properties in both schemas but having
with different values.
message: a string with additional information.
"""
test_case = TestCase('__init__')
test_case.maxDiff = None
status = 'OK'
correct = []
missing = []
distinct = []
msg = ''
for pname, pvalue in self.get_properties().items():
if pname not in schema.get_properties():
missing.append(pname)
msg = msg + '\n' + '* Missing property: ' + pname
status = 'KO'
else:
try:
test_case.assertDictEqual(pvalue,
schema.get_properties()[pname])
correct.append(pname)
except AssertionError as e:
distinct.append(pname)
msg = "%s\n* Type mismatch: \n\t%s: %s" %\
(msg, pname, str(e).replace('\n', '\n\t'))
status = 'KO'
return {'status': status, 'correct': correct, 'missing': missing,
'distinct': distinct, 'msg': msg}