@@ -538,13 +538,17 @@ class FileTestCase(unittest.TestCase):
538
538
539
539
def test_init (self ):
540
540
with LZMAFile (BytesIO (COMPRESSED_XZ )) as f :
541
- pass
541
+ self .assertIsInstance (f , LZMAFile )
542
+ self .assertEqual (f .mode , "rb" )
542
543
with LZMAFile (BytesIO (), "w" ) as f :
543
- pass
544
+ self .assertIsInstance (f , LZMAFile )
545
+ self .assertEqual (f .mode , "wb" )
544
546
with LZMAFile (BytesIO (), "x" ) as f :
545
- pass
547
+ self .assertIsInstance (f , LZMAFile )
548
+ self .assertEqual (f .mode , "wb" )
546
549
with LZMAFile (BytesIO (), "a" ) as f :
547
- pass
550
+ self .assertIsInstance (f , LZMAFile )
551
+ self .assertEqual (f .mode , "wb" )
548
552
549
553
def test_init_with_PathLike_filename (self ):
550
554
filename = FakePath (TESTFN )
@@ -573,26 +577,32 @@ def test_init_with_filename(self):
573
577
574
578
def test_init_mode (self ):
575
579
with TempFile (TESTFN ):
576
- with LZMAFile (TESTFN , "r" ):
577
- pass
578
- with LZMAFile (TESTFN , "rb" ):
579
- pass
580
- with LZMAFile (TESTFN , "w" ):
581
- pass
582
- with LZMAFile (TESTFN , "wb" ):
583
- pass
584
- with LZMAFile (TESTFN , "a" ):
585
- pass
586
- with LZMAFile (TESTFN , "ab" ):
587
- pass
580
+ with LZMAFile (TESTFN , "r" ) as f :
581
+ self .assertIsInstance (f , LZMAFile )
582
+ self .assertEqual (f .mode , "rb" )
583
+ with LZMAFile (TESTFN , "rb" ) as f :
584
+ self .assertIsInstance (f , LZMAFile )
585
+ self .assertEqual (f .mode , "rb" )
586
+ with LZMAFile (TESTFN , "w" ) as f :
587
+ self .assertIsInstance (f , LZMAFile )
588
+ self .assertEqual (f .mode , "wb" )
589
+ with LZMAFile (TESTFN , "wb" ) as f :
590
+ self .assertIsInstance (f , LZMAFile )
591
+ self .assertEqual (f .mode , "wb" )
592
+ with LZMAFile (TESTFN , "a" ) as f :
593
+ self .assertIsInstance (f , LZMAFile )
594
+ self .assertEqual (f .mode , "wb" )
595
+ with LZMAFile (TESTFN , "ab" ) as f :
596
+ self .assertIsInstance (f , LZMAFile )
597
+ self .assertEqual (f .mode , "wb" )
588
598
589
599
def test_init_with_x_mode (self ):
590
600
self .addCleanup (unlink , TESTFN )
591
601
for mode in ("x" , "xb" ):
592
602
unlink (TESTFN )
593
603
with LZMAFile (TESTFN , mode ) as f :
594
- pass
595
- self .assertEqual (f .mode , 'wb' )
604
+ self . assertIsInstance ( f , LZMAFile )
605
+ self .assertEqual (f .mode , 'wb' )
596
606
with self .assertRaises (FileExistsError ):
597
607
LZMAFile (TESTFN , mode )
598
608
0 commit comments