本文整理匯總了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)