File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1470,6 +1470,8 @@ def from_dict(dct: Dict[str, Any]) -> AbstractFileSystem:
14701470 """
14711471 from .json import FilesystemJSONDecoder
14721472
1473+ dct = dict (dct ) # Defensive copy
1474+
14731475 cls = FilesystemJSONDecoder .try_resolve_fs_cls (dct )
14741476 if cls is None :
14751477 raise ValueError ("Not a serialized AbstractFileSystem" )
Original file line number Diff line number Diff line change @@ -888,6 +888,30 @@ def test_json_fs_attr():
888888 assert DummyTestFS .from_json (outb ) is b
889889
890890
891+ def test_dict ():
892+ a = DummyTestFS (1 )
893+ b = DummyTestFS (2 , bar = 1 )
894+
895+ outa = a .to_dict ()
896+ outb = b .to_dict ()
897+
898+ assert isinstance (outa , dict )
899+ assert a != b
900+ assert "bar" in outb
901+
902+ assert DummyTestFS .from_dict (outa ) is a
903+ assert DummyTestFS .from_dict (outb ) is b
904+
905+
906+ def test_dict_idempotent ():
907+ a = DummyTestFS (1 )
908+
909+ outa = a .to_dict ()
910+
911+ assert DummyTestFS .from_dict (outa ) is a
912+ assert DummyTestFS .from_dict (outa ) is a
913+
914+
891915def test_from_dict_valid ():
892916 fs = DummyTestFS .from_dict ({"cls" : "fsspec.tests.test_spec.DummyTestFS" })
893917 assert isinstance (fs , DummyTestFS )
You can’t perform that action at this time.
0 commit comments