當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。