def test_get_fingerprint_with_child_versions(self):
# Make sure _get_fingerprint() generates a consistent fingerprint
# when child_versions are present
child_versions = {'1.0': '1.0', '1.1': '1.1'}
MyObject.VERSION = '1.1'
MyObject.child_versions = child_versions
argspec = 'onix'
with mock.patch('inspect.getargspec') as mock_gas:
mock_gas.return_value = argspec
fp = self.ovc._get_fingerprint(MyObject.__name__)
exp_fields = sorted(list(MyObject.fields.items()))
exp_methods = sorted([('remotable_method', argspec),
('remotable_classmethod', argspec)])
exp_child_versions = collections.OrderedDict(sorted(
child_versions.items()))
exp_relevant_data = (exp_fields, exp_methods, exp_child_versions)
expected_hash = hashlib.md5(six.binary_type(repr(
exp_relevant_data).encode())).hexdigest()
expected_fp = '%s-%s' % (MyObject.VERSION, expected_hash)
self.assertEqual(expected_fp, fp, "_get_fingerprint() did not "
"generate a correct fingerprint.")
test_fixture.py 文件源码
python
阅读 17
收藏 0
点赞 0
评论 0
评论列表
文章目录