spec.py: fix comparison with multivalued variants (#47485)

This commit is contained in:
Harmen Stoppels 2024-11-07 20:29:37 +01:00 committed by GitHub
parent bf11fb037b
commit 0d817878ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -1975,3 +1975,7 @@ def test_equality_discriminate_on_propagation(lhs, rhs):
s, t = Spec(lhs), Spec(rhs)
assert s != t
assert len({s, t}) == 2
def test_comparison_multivalued_variants():
assert Spec("x=a") < Spec("x=a,b") < Spec("x==a,b") < Spec("x==a,b,c")

View File

@ -378,8 +378,8 @@ def _value_setter(self, value: ValueType) -> None:
def _cmp_iter(self) -> Iterable:
yield self.name
yield from (str(v) for v in self.value_as_tuple)
yield self.propagate
yield from (str(v) for v in self.value_as_tuple)
def copy(self) -> "AbstractVariant":
"""Returns an instance of a variant equivalent to self