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


Python Spec.constrain方法代码示例

本文整理汇总了Python中spack.spec.Spec.constrain方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.constrain方法的具体用法?Python Spec.constrain怎么用?Python Spec.constrain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spack.spec.Spec的用法示例。


在下文中一共展示了Spec.constrain方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_invalid_constraint

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import constrain [as 别名]
def check_invalid_constraint(spec, constraint):
    spec = Spec(spec)
    constraint = Spec(constraint)
    with pytest.raises(UnsatisfiableSpecError):
        spec.constrain(constraint)
开发者ID:LLNL,项目名称:spack,代码行数:7,代码来源:spec_semantics.py

示例2: check_constrain

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import constrain [as 别名]
def check_constrain(expected, spec, constraint):
    exp = Spec(expected)
    spec = Spec(spec)
    constraint = Spec(constraint)
    spec.constrain(constraint)
    assert exp == spec
开发者ID:LLNL,项目名称:spack,代码行数:8,代码来源:spec_semantics.py

示例3: check_constrain_not_changed

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import constrain [as 别名]
def check_constrain_not_changed(spec, constraint):
    spec = Spec(spec)
    assert not spec.constrain(constraint)
开发者ID:LLNL,项目名称:spack,代码行数:5,代码来源:spec_semantics.py

示例4: test_unsatisfiable_multi_value_variant

# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import constrain [as 别名]
    def test_unsatisfiable_multi_value_variant(self):

        # Semantics for a multi-valued variant is different
        # Depending on whether the spec is concrete or not

        a = target_factory(
            'multivalue_variant foo="bar"', target_concrete=True
        )
        spec_str = 'multivalue_variant foo="bar,baz"'
        b = Spec(spec_str)
        assert not a.satisfies(b)
        assert not a.satisfies(spec_str)
        # A concrete spec cannot be constrained further
        with pytest.raises(UnsatisfiableSpecError):
            a.constrain(b)

        a = Spec('multivalue_variant foo="bar"')
        spec_str = 'multivalue_variant foo="bar,baz"'
        b = Spec(spec_str)
        # The specs are abstract and they **could** be constrained
        assert a.satisfies(b)
        assert a.satisfies(spec_str)
        # An abstract spec can instead be constrained
        assert a.constrain(b)

        a = target_factory(
            'multivalue_variant foo="bar,baz"', target_concrete=True
        )
        spec_str = 'multivalue_variant foo="bar,baz,quux"'
        b = Spec(spec_str)
        assert not a.satisfies(b)
        assert not a.satisfies(spec_str)
        # A concrete spec cannot be constrained further
        with pytest.raises(UnsatisfiableSpecError):
            a.constrain(b)

        a = Spec('multivalue_variant foo="bar,baz"')
        spec_str = 'multivalue_variant foo="bar,baz,quux"'
        b = Spec(spec_str)
        # The specs are abstract and they **could** be constrained
        assert a.satisfies(b)
        assert a.satisfies(spec_str)
        # An abstract spec can instead be constrained
        assert a.constrain(b)
        # ...but will fail during concretization if there are
        # values in the variant that are not allowed
        with pytest.raises(InvalidVariantValueError):
            a.concretize()

        # This time we'll try to set a single-valued variant
        a = Spec('multivalue_variant fee="bar"')
        spec_str = 'multivalue_variant fee="baz"'
        b = Spec(spec_str)
        # The specs are abstract and they **could** be constrained,
        # as before concretization I don't know which type of variant
        # I have (if it is not a BV)
        assert a.satisfies(b)
        assert a.satisfies(spec_str)
        # A variant cannot be parsed as single-valued until we try to
        # concretize. This means that we can constrain the variant above
        assert a.constrain(b)
        # ...but will fail during concretization if there are
        # multiple values set
        with pytest.raises(MultipleValuesInExclusiveVariantError):
            a.concretize()
开发者ID:LLNL,项目名称:spack,代码行数:67,代码来源:spec_semantics.py


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