本文整理汇总了Python中conans.model.settings.Settings.constraint方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.constraint方法的具体用法?Python Settings.constraint怎么用?Python Settings.constraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类conans.model.settings.Settings
的用法示例。
在下文中一共展示了Settings.constraint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SettingsTest
# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import constraint [as 别名]
#.........这里部分代码省略.........
('compiler.version', '10'),
('compiler.version.arch', '32')]
self.assertEqual(settings.values_list,
[('compiler', 'Visual Studio'),
('compiler.version', '10'),
('compiler.version.arch', '32')])
settings.compiler.version = "10"
settings.compiler.version.arch = "32"
settings.compiler.version = "11"
settings.compiler.version.arch = "64"
settings.compiler.version = "12"
settings.compiler.version.arch = "64"
self.assertEqual(settings.values_list,
[('compiler', 'Visual Studio'),
('compiler.version', '12'),
('compiler.version.arch', '64')])
def set_value_test(self):
self.sut.values_list = [("compiler", "Visual Studio")]
self.assertEqual(self.sut.compiler, "Visual Studio")
self.sut.values_list = [("compiler.version", "12")]
self.assertEqual(self.sut.compiler.version, "12")
self.sut.values_list = [("compiler", "gcc")]
self.assertEqual(self.sut.compiler, "gcc")
self.sut.values_list = [("compiler.version", "4.8")]
self.assertEqual(self.sut.compiler.version, "4.8")
self.sut.values_list = [("compiler.arch", "x86")]
self.assertEqual(self.sut.compiler.arch, "x86")
self.sut.values_list = [("compiler.arch.speed", "A")]
self.assertEqual(self.sut.compiler.arch.speed, "A")
def constraint_test(self):
s2 = {"os": None}
self.sut.constraint(s2)
with self.assertRaises(ConanException) as cm:
self.sut.compiler
self.assertEqual(str(cm.exception), str(undefined_field("settings", "compiler", ["os"])))
self.sut.os = "Windows"
self.sut.os = "Linux"
def constraint2_test(self):
s2 = {"os2": None}
with self.assertRaises(ConanException) as cm:
self.sut.constraint(s2)
self.assertEqual(str(cm.exception),
str(undefined_field("settings", "os2", ["compiler", "os"])))
def constraint3_test(self):
s2 = {"os": ["Win"]}
with self.assertRaises(ConanException) as cm:
self.sut.constraint(s2)
self.assertEqual(str(cm.exception),
bad_value_msg("os", "Win", ["Linux", "Windows"]))
def constraint4_test(self):
s2 = {"os": ["Windows"]}
self.sut.constraint(s2)
with self.assertRaises(ConanException) as cm:
self.sut.os = "Linux"
self.assertEqual(str(cm.exception), bad_value_msg("settings.os", "Linux", ["Windows"]))
self.sut.os = "Windows"
def constraint5_test(self):