当前位置: 首页>>代码示例>>Python>>正文


Python Settings.constraint方法代码示例

本文整理汇总了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):
开发者ID:19317362,项目名称:conan,代码行数:70,代码来源:settings_test.py


注:本文中的conans.model.settings.Settings.constraint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。