File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1616from  fsspec .implementations .local  import  LocalFileSystem 
1717from  fsspec .spec  import  AbstractBufferedFile , AbstractFileSystem 
1818
19+ from  fsspec .tests .conftest  import  data , server 
20+ 
1921PATHS_FOR_GLOB_TESTS  =  (
2022    {"name" : "test0.json" , "type" : "file" , "size" : 100 },
2123    {"name" : "test0.yaml" , "type" : "file" , "size" : 100 },
@@ -744,6 +746,26 @@ def test_cache():
744746    assert  len (DummyTestFS ._cache ) ==  0 
745747
746748
749+ def  test_cache_not_pickled (server ):
750+     fs  =  fsspec .filesystem ("http" )
751+     filepath  =  server .realfile 
752+     length  =  3 
753+     f  =  fs .open (filepath , mode = "rb" )
754+     assert  not  f .cache .cache   # No cache initially 
755+     assert  f .read (length = length ) ==  data [:length ]
756+     assert  f .cache .cache  ==  data   # Cache is populated 
757+ 
758+     # Roundtrip through pickle 
759+     import  pickle 
760+ 
761+     f2  =  pickle .loads (pickle .dumps (f ))
762+     assert  not  f2 .cache .cache   # No cache initially 
763+     assert  (
764+         f2 .read (length = length ) ==  data [length  : 2  *  length ]
765+     )  # Read file from previous seek point 
766+     assert  f2 .cache .cache  ==  data [length :]  # Cache is populated 
767+ 
768+ 
747769def  test_current ():
748770    fs  =  DummyTestFS ()
749771    fs2  =  DummyTestFS (arg = 1 )
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments