本文整理汇总了Python中conans.model.settings.Settings.validate方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.validate方法的具体用法?Python Settings.validate怎么用?Python Settings.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类conans.model.settings.Settings
的用法示例。
在下文中一共展示了Settings.validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SettingsTest
# 需要导入模块: from conans.model.settings import Settings [as 别名]
# 或者: from conans.model.settings.Settings import validate [as 别名]
class SettingsTest(unittest.TestCase):
def setUp(self):
data = {"compiler": {
"Visual Studio": {
"version": ["10", "11", "12"],
"runtime": ["MD", "MT"]},
"gcc": {
"version": ["4.8", "4.9"],
"arch": {"x86": {"speed": ["A", "B"]},
"x64": {"speed": ["C", "D"]}}}
},
"os": ["Windows", "Linux"]}
self.sut = Settings(data)
def test_in_contains(self):
self.sut.compiler = "Visual Studio"
self.assertTrue("Visual" in self.sut.compiler)
self.assertFalse("Visual" not in self.sut.compiler)
def test_os_split(self):
settings = Settings.loads("""os:
Windows:
Linux:
Macos:
version: [1, 2]
Android:
""")
other_settings = Settings.loads("os: [Windows, Linux]")
settings.os = "Windows"
other_settings.os = "Windows"
self.assertEqual(settings.values.sha, other_settings.values.sha)
def any_test(self):
data = {"target": "ANY"}
sut = Settings(data)
sut.target = "native"
self.assertTrue(sut.target == "native")
def multi_os_test(self):
settings = Settings.loads("""os:
Windows:
Linux:
distro: [RH6, RH7]
Macos:
codename: [Mavericks, Yosemite]
""")
settings.os = "Windows"
self.assertEqual(settings.os, "Windows")
settings.os = "Linux"
settings.os.distro = "RH6"
self.assertTrue(settings.os.distro == "RH6")
with self.assertRaises(ConanException):
settings.os.distro = "Other"
with self.assertRaises(ConanException):
settings.os.codename = "Yosemite"
settings.os = "Macos"
settings.os.codename = "Yosemite"
self.assertTrue(settings.os.codename == "Yosemite")
def remove_test(self):
self.sut.remove("compiler")
self.sut.os = "Windows"
self.sut.validate()
self.assertEqual(self.sut.values.dumps(), "os=Windows")
def remove_compiler_test(self):
self.sut.compiler.remove("Visual Studio")
with self.assertRaises(ConanException) as cm:
self.sut.compiler = "Visual Studio"
self.assertEqual(str(cm.exception),
bad_value_msg("settings.compiler", "Visual Studio", ["gcc"]))
def remove_version_test(self):
self.sut.compiler["Visual Studio"].version.remove("12")
self.sut.compiler = "Visual Studio"
with self.assertRaises(ConanException) as cm:
self.sut.compiler.version = "12"
self.assertEqual(str(cm.exception),
bad_value_msg("settings.compiler.version", "12", ["10", "11"]))
self.sut.compiler.version = 11
self.assertEqual(self.sut.compiler.version, "11")
def remove_os_test(self):
self.sut.os.remove("Windows")
with self.assertRaises(ConanException) as cm:
self.sut.os = "Windows"
self.assertEqual(str(cm.exception),
bad_value_msg("settings.os", "Windows", ["Linux"]))
self.sut.os = "Linux"
self.assertEqual(self.sut.os, "Linux")
def loads_default_test(self):
settings = Settings.loads("""os: [Windows, Linux, Macos, Android, FreeBSD, SunOS]
arch: [x86, x86_64, arm]
compiler:
sun-cc:
version: ["5.10", "5.11", "5.12", "5.13", "5.14"]
gcc:
version: ["4.8", "4.9", "5.0"]
#.........这里部分代码省略.........