@@ -2066,13 +2066,13 @@ def test_repack_data_descriptor_no_sig(self):
20662066 # calculate the expected results
20672067 test_files = [data for j , data in enumerate (self .test_files ) if j not in ii ]
20682068 with open (TESTFN , 'wb' ) as fh :
2069- with mock .patch ( 'zipfile. struct. pack' , side_effect = struct_pack_no_dd_sig ):
2069+ with mock .patch . object ( struct , ' pack' , side_effect = struct_pack_no_dd_sig ):
20702070 expected_zinfos = self ._prepare_zip_from_test_files (Unseekable (fh ), test_files )
20712071 expected_size = os .path .getsize (TESTFN )
20722072
20732073 # do the removal and check the result
20742074 with open (TESTFN , 'wb' ) as fh :
2075- with mock .patch ( 'zipfile. struct. pack' , side_effect = struct_pack_no_dd_sig ):
2075+ with mock .patch . object ( struct , ' pack' , side_effect = struct_pack_no_dd_sig ):
20762076 zinfos = self ._prepare_zip_from_test_files (Unseekable (fh ), self .test_files )
20772077 with zipfile .ZipFile (TESTFN , 'a' , self .compression ) as zh :
20782078 # make sure data descriptor bit is really set (by making zipfile unseekable)
@@ -2105,7 +2105,7 @@ def test_repack_data_descriptor_no_sig_strict(self):
21052105 with self .subTest (remove = ii ):
21062106 # calculate the expected results
21072107 with open (TESTFN , 'wb' ) as fh :
2108- with mock .patch ( 'zipfile. struct. pack' , side_effect = struct_pack_no_dd_sig ):
2108+ with mock .patch . object ( struct , ' pack' , side_effect = struct_pack_no_dd_sig ):
21092109 self ._prepare_zip_from_test_files (Unseekable (fh ), self .test_files )
21102110 with zipfile .ZipFile (TESTFN , 'a' ) as zh :
21112111 for i in ii :
@@ -2115,7 +2115,7 @@ def test_repack_data_descriptor_no_sig_strict(self):
21152115
21162116 # do the removal and check the result
21172117 with open (TESTFN , 'wb' ) as fh :
2118- with mock .patch ( 'zipfile. struct. pack' , side_effect = struct_pack_no_dd_sig ):
2118+ with mock .patch . object ( struct , ' pack' , side_effect = struct_pack_no_dd_sig ):
21192119 zinfos = self ._prepare_zip_from_test_files (Unseekable (fh ), self .test_files )
21202120 with zipfile .ZipFile (TESTFN , 'a' , self .compression ) as zh :
21212121 # make sure data descriptor bit is really set (by making zipfile unseekable)
@@ -2150,13 +2150,13 @@ def test_repack_data_descriptor_no_sig_strict_by_decompressoin(self):
21502150 # calculate the expected results
21512151 test_files = [data for j , data in enumerate (self .test_files ) if j not in ii ]
21522152 with open (TESTFN , 'wb' ) as fh :
2153- with mock .patch ( 'zipfile. struct. pack' , side_effect = struct_pack_no_dd_sig ):
2153+ with mock .patch . object ( struct , ' pack' , side_effect = struct_pack_no_dd_sig ):
21542154 expected_zinfos = self ._prepare_zip_from_test_files (Unseekable (fh ), test_files )
21552155 expected_size = os .path .getsize (TESTFN )
21562156
21572157 # do the removal and check the result
21582158 with open (TESTFN , 'wb' ) as fh :
2159- with mock .patch ( 'zipfile. struct. pack' , side_effect = struct_pack_no_dd_sig ):
2159+ with mock .patch . object ( struct , ' pack' , side_effect = struct_pack_no_dd_sig ):
21602160 zinfos = self ._prepare_zip_from_test_files (Unseekable (fh ), self .test_files )
21612161 with zipfile .ZipFile (TESTFN , 'a' , self .compression ) as zh :
21622162 # make sure data descriptor bit is really set (by making zipfile unseekable)
@@ -2187,13 +2187,13 @@ def test_repack_data_descriptor_no_sig_and_zip64(self):
21872187 # calculate the expected results
21882188 test_files = [data for j , data in enumerate (self .test_files ) if j not in ii ]
21892189 with open (TESTFN , 'wb' ) as fh :
2190- with mock .patch ( 'zipfile. struct. pack' , side_effect = struct_pack_no_dd_sig ):
2190+ with mock .patch . object ( struct , ' pack' , side_effect = struct_pack_no_dd_sig ):
21912191 expected_zinfos = self ._prepare_zip_from_test_files (Unseekable (fh ), test_files , force_zip64 = True )
21922192 expected_size = os .path .getsize (TESTFN )
21932193
21942194 # do the removal and check the result
21952195 with open (TESTFN , 'wb' ) as fh :
2196- with mock .patch ( 'zipfile. struct. pack' , side_effect = struct_pack_no_dd_sig ):
2196+ with mock .patch . object ( struct , ' pack' , side_effect = struct_pack_no_dd_sig ):
21972197 zinfos = self ._prepare_zip_from_test_files (Unseekable (fh ), self .test_files , force_zip64 = True )
21982198 with zipfile .ZipFile (TESTFN , 'a' , self .compression ) as zh :
21992199 # make sure data descriptor bit is really set (by making zipfile unseekable)
@@ -2345,7 +2345,7 @@ def test_repack_removed_bad_removed_zinfos(self):
23452345 with self .assertRaises (zipfile .BadZipFile ):
23462346 zh .repack (zinfos )
23472347
2348- @mock .patch ( ' zipfile. _ZipRepacker' )
2348+ @mock .patch . object ( zipfile , ' _ZipRepacker' )
23492349 def test_repack_closed (self , m_repack ):
23502350 self ._prepare_zip_from_test_files (TESTFN , self .test_files )
23512351 with zipfile .ZipFile (TESTFN , 'a' ) as zh :
@@ -2354,7 +2354,7 @@ def test_repack_closed(self, m_repack):
23542354 zh .repack ()
23552355 m_repack .assert_not_called ()
23562356
2357- @mock .patch ( ' zipfile. _ZipRepacker' )
2357+ @mock .patch . object ( zipfile , ' _ZipRepacker' )
23582358 def test_repack_writing (self , m_repack ):
23592359 self ._prepare_zip_from_test_files (TESTFN , self .test_files )
23602360 with zipfile .ZipFile (TESTFN , 'a' ) as zh :
@@ -2363,22 +2363,22 @@ def test_repack_writing(self, m_repack):
23632363 zh .repack ()
23642364 m_repack .assert_not_called ()
23652365
2366- @mock .patch ( ' zipfile. _ZipRepacker' )
2366+ @mock .patch . object ( zipfile , ' _ZipRepacker' )
23672367 def test_repack_mode_r (self , m_repack ):
23682368 self ._prepare_zip_from_test_files (TESTFN , self .test_files )
23692369 with zipfile .ZipFile (TESTFN , 'r' ) as zh :
23702370 with self .assertRaises (ValueError ):
23712371 zh .repack ()
23722372 m_repack .assert_not_called ()
23732373
2374- @mock .patch ( ' zipfile. _ZipRepacker' )
2374+ @mock .patch . object ( zipfile , ' _ZipRepacker' )
23752375 def test_repack_mode_w (self , m_repack ):
23762376 with zipfile .ZipFile (TESTFN , 'w' ) as zh :
23772377 with self .assertRaises (ValueError ):
23782378 zh .repack ()
23792379 m_repack .assert_not_called ()
23802380
2381- @mock .patch ( ' zipfile. _ZipRepacker' )
2381+ @mock .patch . object ( zipfile , ' _ZipRepacker' )
23822382 def test_repack_mode_x (self , m_repack ):
23832383 with zipfile .ZipFile (TESTFN , 'x' ) as zh :
23842384 with self .assertRaises (ValueError ):
0 commit comments