File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1542,6 +1542,40 @@ def read(self, size=-1):
15421542            with  self .assertRaisesRegex (AttributeError , r'fileno' ):
15431543                f .fileno ()
15441544
1545+     def  test_name (self ):
1546+         # 1 
1547+         f  =  ZstdFile (io .BytesIO (COMPRESSED_100_PLUS_32KB ))
1548+         try :
1549+             with  self .assertRaises (AttributeError ):
1550+                 f .name 
1551+         finally :
1552+             f .close ()
1553+         with  self .assertRaises (ValueError ):
1554+             f .name 
1555+ 
1556+         # 2 
1557+         with  tempfile .NamedTemporaryFile (delete = False ) as  tmp_f :
1558+             filename  =  pathlib .Path (tmp_f .name )
1559+ 
1560+         f  =  ZstdFile (filename )
1561+         try :
1562+             self .assertEqual (f .name , f ._fp .name )
1563+             self .assertIsInstance (f .name , str )
1564+         finally :
1565+             f .close ()
1566+         with  self .assertRaises (ValueError ):
1567+             f .name 
1568+ 
1569+         os .remove (filename )
1570+ 
1571+         # 3, no .filename property 
1572+         class  C :
1573+             def  read (self , size = - 1 ):
1574+                 return  b'123' 
1575+         with  ZstdFile (C (), 'rb' ) as  f :
1576+             with  self .assertRaisesRegex (AttributeError , r'name' ):
1577+                 f .name 
1578+ 
15451579    def  test_seekable (self ):
15461580        f  =  ZstdFile (io .BytesIO (COMPRESSED_100_PLUS_32KB ))
15471581        try :
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments