|
16 | 16 |
|
17 | 17 | # Helper functions for backward compatibility with tests |
18 | 18 | def dumps_helper(serializer: JsonPlusRedisSerializer, obj): |
19 | | - """Helper to simulate old dumps() method using dumps_typed().""" |
20 | | - type_str, data_bytes = serializer.dumps_typed(obj) |
21 | | - return data_bytes |
| 19 | + """Helper to simulate old dumps() method using dumps_typed(). |
| 20 | +
|
| 21 | + Returns the full (type_str, data_bytes) tuple to preserve type information. |
| 22 | + """ |
| 23 | + return serializer.dumps_typed(obj) |
22 | 24 |
|
23 | 25 |
|
24 | | -def loads_helper(serializer: JsonPlusRedisSerializer, data_bytes): |
25 | | - """Helper to simulate old loads() method using loads_typed().""" |
26 | | - # Assume JSON type for these tests |
27 | | - return serializer.loads_typed(("json", data_bytes)) |
| 26 | +def loads_helper(serializer: JsonPlusRedisSerializer, typed_data): |
| 27 | + """Helper to simulate old loads() method using loads_typed(). |
| 28 | +
|
| 29 | + Args: |
| 30 | + typed_data: Full (type_str, data_bytes) tuple from dumps_helper |
| 31 | + """ |
| 32 | + return serializer.loads_typed(typed_data) |
28 | 33 |
|
29 | 34 |
|
30 | 35 | def test_serializer_uses_default_handler_for_messages(): |
@@ -153,7 +158,8 @@ def test_dumps_typed_with_messages(): |
153 | 158 | type_str, blob = serializer.dumps_typed(msg) |
154 | 159 |
|
155 | 160 | assert type_str == "json" |
156 | | - assert isinstance(blob, str) |
| 161 | + # Checkpoint 3.0: dumps_typed now returns bytes, not str |
| 162 | + assert isinstance(blob, bytes) |
157 | 163 |
|
158 | 164 | # Deserialize |
159 | 165 | deserialized = serializer.loads_typed((type_str, blob)) |
|
0 commit comments