|
18 | 18 | from django_valkey.cluster_cache.client import DefaultClusterClient |
19 | 19 | from django_valkey.serializers.json import JSONSerializer |
20 | 20 | from django_valkey.serializers.msgpack import MSGPackSerializer |
| 21 | +from django_valkey.serializers.msgspec import ( |
| 22 | + MsgSpecJsonSerializer, |
| 23 | + MsgSpecMsgPackSerializer, |
| 24 | +) |
21 | 25 | from django_valkey.serializers.pickle import PickleSerializer |
22 | 26 |
|
23 | 27 |
|
@@ -128,7 +132,15 @@ def test_save_unicode(self, cache: ValkeyCache): |
128 | 132 | assert res == "heló" |
129 | 133 |
|
130 | 134 | def test_save_dict(self, cache: ValkeyCache): |
131 | | - if isinstance(cache.client._serializer, (JSONSerializer, MSGPackSerializer)): |
| 135 | + if isinstance( |
| 136 | + cache.client._serializer, |
| 137 | + ( |
| 138 | + JSONSerializer, |
| 139 | + MSGPackSerializer, |
| 140 | + MsgSpecJsonSerializer, |
| 141 | + MsgSpecMsgPackSerializer, |
| 142 | + ), |
| 143 | + ): |
132 | 144 | # JSONSerializer and MSGPackSerializer use the isoformat for |
133 | 145 | # datetimes. |
134 | 146 | now_dt: str | datetime.datetime = datetime.datetime.now().isoformat() |
@@ -1099,9 +1111,17 @@ def test_sismember_memoryview(self, cache: ValkeyCache): |
1099 | 1111 | assert cache.sismember("foo", wrong_val) is False |
1100 | 1112 |
|
1101 | 1113 | def test_sismember_complex(self, cache: ValkeyCache): |
1102 | | - if isinstance(cache.client._serializer, (JSONSerializer, MSGPackSerializer)): |
| 1114 | + if isinstance( |
| 1115 | + cache.client._serializer, |
| 1116 | + ( |
| 1117 | + JSONSerializer, |
| 1118 | + MSGPackSerializer, |
| 1119 | + MsgSpecJsonSerializer, |
| 1120 | + MsgSpecMsgPackSerializer, |
| 1121 | + ), |
| 1122 | + ): |
1103 | 1123 | pytest.skip( |
1104 | | - "JSONSerializer/MSGPackSerializer doesn't support the complex type" |
| 1124 | + "JSONSerializer/MSGPackSerializer and neither the msgspec serializers don't support the complex type" |
1105 | 1125 | ) |
1106 | 1126 | cache.sadd("foo", 3j) |
1107 | 1127 | assert cache.sismember("foo", 3j) is True |
|
0 commit comments