diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2022-09-21 19:22:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-21 19:22:58 +0200 |
commit | 7e01a1252a846c2b20becb4488cb1bb95f2863d9 (patch) | |
tree | 38f0d2377a32355b80e5bfda9ebd424811e84a7d | |
parent | d07b200b6704d821555b6b8e02a94d731ffb5168 (diff) | |
download | spack-7e01a1252a846c2b20becb4488cb1bb95f2863d9.tar.gz spack-7e01a1252a846c2b20becb4488cb1bb95f2863d9.tar.bz2 spack-7e01a1252a846c2b20becb4488cb1bb95f2863d9.tar.xz spack-7e01a1252a846c2b20becb4488cb1bb95f2863d9.zip |
Allow conditional variants as first values in a variant directive (#32740)
-rw-r--r-- | lib/spack/spack/test/variant.py | 11 | ||||
-rw-r--r-- | lib/spack/spack/variant.py | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/spack/spack/test/variant.py b/lib/spack/spack/test/variant.py index 204514b58d..0284c5ea0c 100644 --- a/lib/spack/spack/test/variant.py +++ b/lib/spack/spack/test/variant.py @@ -2,13 +2,12 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) - - import numbers import pytest import spack.error +import spack.variant from spack.variant import ( BoolValuedVariant, DuplicateVariantError, @@ -737,3 +736,11 @@ def test_disjoint_set_fluent_methods(): assert "none" not in d assert "none" not in [x for x in d] assert "none" not in d.feature_values + + +@pytest.mark.regression("32694") +@pytest.mark.parametrize("other", [True, False]) +def test_conditional_value_comparable_to_bool(other): + value = spack.variant.Value("98", when="@1.0") + comparison = value == other + assert comparison is False diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py index 1f21aad89f..864ea26446 100644 --- a/lib/spack/spack/variant.py +++ b/lib/spack/spack/variant.py @@ -886,7 +886,7 @@ class Value(object): return hash(self.value) def __eq__(self, other): - if isinstance(other, six.string_types): + if isinstance(other, (six.string_types, bool)): return self.value == other return self.value == other.value |