|
23 | 23 | unregister_unpack_format, get_unpack_formats, |
24 | 24 | SameFileError, _GiveupOnFastCopy) |
25 | 25 | import tarfile |
| 26 | +import warnings |
26 | 27 | import zipfile |
27 | 28 | try: |
28 | 29 | import posix |
@@ -207,7 +208,8 @@ def test_rmtree_fails_on_symlink_onerror(self): |
207 | 208 | errors = [] |
208 | 209 | def onerror(*args): |
209 | 210 | errors.append(args) |
210 | | - shutil.rmtree(link, onerror=onerror) |
| 211 | + with self.assertWarns(DeprecationWarning): |
| 212 | + shutil.rmtree(link, onerror=onerror) |
211 | 213 | self.assertEqual(len(errors), 1) |
212 | 214 | self.assertIs(errors[0][0], os.path.islink) |
213 | 215 | self.assertEqual(errors[0][1], link) |
@@ -268,7 +270,8 @@ def test_rmtree_fails_on_junctions_onerror(self): |
268 | 270 | errors = [] |
269 | 271 | def onerror(*args): |
270 | 272 | errors.append(args) |
271 | | - shutil.rmtree(link, onerror=onerror) |
| 273 | + with self.assertWarns(DeprecationWarning): |
| 274 | + shutil.rmtree(link, onerror=onerror) |
272 | 275 | self.assertEqual(len(errors), 1) |
273 | 276 | self.assertIs(errors[0][0], os.path.islink) |
274 | 277 | self.assertEqual(errors[0][1], link) |
@@ -337,7 +340,8 @@ def test_rmtree_errors_onerror(self): |
337 | 340 | errors = [] |
338 | 341 | def onerror(*args): |
339 | 342 | errors.append(args) |
340 | | - shutil.rmtree(filename, onerror=onerror) |
| 343 | + with self.assertWarns(DeprecationWarning): |
| 344 | + shutil.rmtree(filename, onerror=onerror) |
341 | 345 | self.assertEqual(len(errors), 2) |
342 | 346 | self.assertIs(errors[0][0], os.scandir) |
343 | 347 | self.assertEqual(errors[0][1], filename) |
@@ -406,7 +410,8 @@ def test_on_error(self): |
406 | 410 | self.addCleanup(os.chmod, self.child_file_path, old_child_file_mode) |
407 | 411 | self.addCleanup(os.chmod, self.child_dir_path, old_child_dir_mode) |
408 | 412 |
|
409 | | - shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror) |
| 413 | + with self.assertWarns(DeprecationWarning): |
| 414 | + shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror) |
410 | 415 | # Test whether onerror has actually been called. |
411 | 416 | self.assertEqual(self.errorState, 3, |
412 | 417 | "Expected call to onerror function did not happen.") |
@@ -532,7 +537,8 @@ def onexc(*args): |
532 | 537 | self.addCleanup(os.chmod, self.child_file_path, old_child_file_mode) |
533 | 538 | self.addCleanup(os.chmod, self.child_dir_path, old_child_dir_mode) |
534 | 539 |
|
535 | | - shutil.rmtree(TESTFN, onerror=onerror, onexc=onexc) |
| 540 | + with self.assertWarns(DeprecationWarning): |
| 541 | + shutil.rmtree(TESTFN, onerror=onerror, onexc=onexc) |
536 | 542 | self.assertTrue(onexc_called) |
537 | 543 | self.assertFalse(onerror_called) |
538 | 544 |
|
|
0 commit comments