Allow conditional variants as first values in a variant directive (#32740)

This commit is contained in:
Massimiliano Culpo 2022-09-21 19:22:58 +02:00 committed by GitHub
parent d07b200b67
commit 7e01a1252a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -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

View file

@ -886,7 +886,7 @@ def __hash__(self):
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