You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/11/02 07:11:32 UTC
(opendal) branch main updated: test(bindings/python): add test for pickle streaming load/write (#5272)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 10d64e262a test(bindings/python): add test for pickle streaming load/write (#5272)
10d64e262a is described below
commit 10d64e262a0286a36abd0e33edd576de3a0fa66e
Author: TennyZhuang <zt...@gmail.com>
AuthorDate: Sat Nov 2 15:11:26 2024 +0800
test(bindings/python): add test for pickle streaming load/write (#5272)
---
bindings/python/tests/test_pickle.py | 47 ++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/bindings/python/tests/test_pickle.py b/bindings/python/tests/test_pickle.py
new file mode 100644
index 0000000000..cba0016282
--- /dev/null
+++ b/bindings/python/tests/test_pickle.py
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import pytest
+import pickle
+from datetime import datetime
+from uuid import uuid4
+
+
+@pytest.mark.need_capability("read", "write", "delete")
+def test_sync_file_pickle(service_name, operator, async_operator):
+ """
+ Test pickle streaming serialization and deserialization using OpenDAL operator.
+ """
+ data = {
+ "a": 1,
+ "b": "hello",
+ "c": [1, 2, 3],
+ "d": {"e": 4},
+ "f": None,
+ "g": b"hello\nworld",
+ "h": set([1, 2, 3]),
+ "i": 1.23,
+ "j": True,
+ "k": datetime.strptime("2024-01-01", "%Y-%m-%d"),
+ }
+
+ filename = f"random_file_{str(uuid4())}"
+ with operator.open(filename, "wb") as f:
+ pickle.dump(data, f)
+
+ with operator.open(filename, "rb") as f:
+ assert pickle.load(f) == data