Skip to content

Commit dca5dce

Browse files
committed
Fix logic for equals expectation; expand primary/secondary independence test.
1 parent 07ed579 commit dca5dce

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

lib/iris/tests/unit/common/metadata/test_CubeMetadata.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,11 @@ def check_splitattrs_testcase(
346346
expected = _ALL_RESULTS[operation_name][primary_key][which]
347347
if operation_name == "equal" and expected:
348348
# Account for the equality cases made `False` by mismatched secondary values.
349-
secondary_1, secondary_2 = secondary_inputs
350-
if (
351-
secondary_1 != "X"
352-
and secondary_2 != "X"
353-
and secondary_1 != secondary_2
354-
):
349+
left, right = secondary_inputs
350+
secondaries_same = left == right or (
351+
check_is_lenient and "X" in (left, right)
352+
)
353+
if not secondaries_same:
355354
expected = False
356355

357356
# Check that actual extracted operation result matches the "expected" one.
@@ -398,7 +397,15 @@ def test_splitattrs_cases(
398397
)
399398

400399
@pytest.mark.parametrize(
401-
"secondary_values", ["secondaryXX", "secondaryCC", "secondaryCD"]
400+
"secondary_values",
401+
[
402+
"secondaryXX",
403+
"secondaryCX",
404+
"secondaryXC",
405+
"secondaryCC",
406+
"secondaryCD",
407+
]
408+
# NOTE: test CX as well as XC, since primary choices has "AX" but not "XA".
402409
)
403410
def test_splitattrs_global_local_independence(
404411
self,
@@ -418,10 +425,9 @@ def test_splitattrs_global_local_independence(
418425
Notes
419426
-----
420427
We provide this *separate* test for global/local attribute independence,
421-
parametrized over selected relevant arrangements of the 'secondary' values, and
422-
do not test with reversed order or "local" primary inputs.
423-
This is because matrix testing over *all* relevant factors simply produces too
424-
many possible combinations.
428+
parametrized over selected relevant arrangements of the 'secondary' values.
429+
We *don't* test with reversed order or "local" primary inputs, because matrix
430+
testing over *all* relevant factors produces too many possible combinations.
425431
"""
426432
primary_inputs = primary_values[-2:]
427433
secondary_inputs = secondary_values[-2:]

0 commit comments

Comments
 (0)