Skip to content

Commit c04e07c

Browse files
committed
tests: tighten assertion in test_recv_results_metadata_no_metadata_flag_skips_metadata_id
The previous assertion used 'not hasattr(...) or ... is None' which would pass even if the code had a bug that explicitly set result_metadata_id = None instead of leaving the attribute absent. result_metadata_id is not a class attribute on ResultMessage, so the correct assertion is 'assert not hasattr(msg, "result_metadata_id")'. column_metadata IS a class attribute (= None), so its assertion is adjusted to 'assert msg.column_metadata is None'.
1 parent c0495a7 commit c04e07c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tests/unit/test_protocol.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,11 @@ def test_recv_results_metadata_no_metadata_flag_skips_metadata_id(self):
226226
)
227227
msg = ResultMessage(kind=RESULT_KIND_ROWS)
228228
msg.recv_results_metadata(buf, user_type_map={})
229-
assert not hasattr(msg, 'result_metadata_id') or msg.result_metadata_id is None
230-
assert not hasattr(msg, 'column_metadata') or msg.column_metadata is None
229+
# recv_results_metadata returns early on NO_METADATA; result_metadata_id
230+
# must never be set as an instance attribute (it is not a class default).
231+
# column_metadata is a class attribute defaulting to None and must remain so.
232+
assert not hasattr(msg, 'result_metadata_id')
233+
assert msg.column_metadata is None
231234

232235
def test_query_message(self):
233236
"""

0 commit comments

Comments
 (0)