本文整理汇总了Python中easybuild.framework.easyconfig.format.version.OrderedVersionOperators.get_data方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedVersionOperators.get_data方法的具体用法?Python OrderedVersionOperators.get_data怎么用?Python OrderedVersionOperators.get_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类easybuild.framework.easyconfig.format.version.OrderedVersionOperators
的用法示例。
在下文中一共展示了OrderedVersionOperators.get_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ordered_versop_add_data
# 需要导入模块: from easybuild.framework.easyconfig.format.version import OrderedVersionOperators [as 别名]
# 或者: from easybuild.framework.easyconfig.format.version.OrderedVersionOperators import get_data [as 别名]
def test_ordered_versop_add_data(self):
"""Test the add and data handling"""
ovop = OrderedVersionOperators()
tests = [
('> 1', '5'),
('> 2', {'x': 3}),
]
for versop_txt, data in tests:
versop = VersionOperator(versop_txt)
ovop.add(versop)
# no data was added, this is a new entry, mapper is initialised with None
self.assertEqual(ovop.get_data(versop), None)
ovop.add(versop, data)
# test data
self.assertEqual(ovop.get_data(versop), data)
# new data for same versops
tests = [
('> 1', '6'),
('> 2', {'x': 4}),
]
for versop_txt, data in tests:
versop = VersionOperator(versop_txt)
ovop.add(versop, data)
# test updated data
self.assertEqual(ovop.get_data(versop), data)
# 'update' a value
# the data for '> 1' has no .update()
extra_data = {'y': 4}
tests = [
('> 2', extra_data),
]
for versop_txt, data in tests:
versop = VersionOperator(versop_txt)
prevdata = copy.deepcopy(ovop.get_data(versop))
prevdata.update(extra_data)
ovop.add(versop, data, update=True)
# test updated data
self.assertEqual(ovop.get_data(versop), prevdata)
# use update=True on new element
versop = VersionOperator('> 10000')
new_data = {'new': 5}
ovop.add(versop, new_data, update=True)
# test updated data
self.assertEqual(ovop.get_data(versop), new_data)