Skip to content

Commit 800b56a

Browse files
authored
test: fix operator precedence in manifest v2 assertions (#3612)
Six assertions in test_write_manifest and test_write_manifest_list used the form `assert x == a if format_version == 1 else b`. Because a conditional expression binds looser than `==`, Python parses this as `assert (x == a) if (format_version == 1) else b`, so for the format_version == 2 parametrization the whole statement collapses to `assert b`, where b is a truthy constant (3, or ManifestContent.DELETES). The v2 branch therefore always passed and never compared the actual value read back from the manifest. Wrap the right-hand side in parentheses so the conditional expression is the comparison target. This restores verification of the v2 sequence_number, content, min_sequence_number, and file_sequence_number on the manifest read/round-trip path. Test-only change; all parametrized cases (v1 and v2) pass. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
1 parent d142bd1 commit 800b56a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tests/utils/test_manifest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def test_write_manifest(
424424

425425
assert manifest_entry.status == ManifestEntryStatus.ADDED
426426
assert manifest_entry.snapshot_id == 8744736658442914487
427-
assert manifest_entry.sequence_number == -1 if format_version == 1 else 3
427+
assert manifest_entry.sequence_number == (-1 if format_version == 1 else 3)
428428
assert isinstance(manifest_entry.data_file, DataFile)
429429

430430
data_file = manifest_entry.data_file
@@ -587,9 +587,9 @@ def test_write_manifest_list(
587587

588588
assert manifest_file.manifest_length == 7989
589589
assert manifest_file.partition_spec_id == 0
590-
assert manifest_file.content == ManifestContent.DATA if format_version == 1 else ManifestContent.DELETES
591-
assert manifest_file.sequence_number == 0 if format_version == 1 else 3
592-
assert manifest_file.min_sequence_number == 0 if format_version == 1 else 3
590+
assert manifest_file.content == (ManifestContent.DATA if format_version == 1 else ManifestContent.DELETES)
591+
assert manifest_file.sequence_number == (0 if format_version == 1 else 3)
592+
assert manifest_file.min_sequence_number == (0 if format_version == 1 else 3)
593593
assert manifest_file.added_snapshot_id == 9182715666859759686
594594
assert manifest_file.added_files_count == 3
595595
assert manifest_file.existing_files_count == 0
@@ -616,8 +616,8 @@ def test_write_manifest_list(
616616

617617
entry = entries[0]
618618

619-
assert entry.sequence_number == 0 if format_version == 1 else 3
620-
assert entry.file_sequence_number == 0 if format_version == 1 else 3
619+
assert entry.sequence_number == (0 if format_version == 1 else 3)
620+
assert entry.file_sequence_number == (0 if format_version == 1 else 3)
621621
assert entry.snapshot_id == 8744736658442914487
622622
assert entry.status == ManifestEntryStatus.ADDED
623623

0 commit comments

Comments
 (0)