@@ -738,6 +738,31 @@ def test_extract_directory(self):
738738 finally :
739739 os_helper .rmtree (DIR )
740740
741+ def test_deprecation_if_no_filter_passed_to_extractall (self ):
742+ DIR = pathlib .Path (TEMPDIR ) / "extractall"
743+ with (
744+ os_helper .temp_dir (DIR ),
745+ tarfile .open (tarname , encoding = "iso8859-1" ) as tar
746+ ):
747+ directories = [t for t in tar if t .isdir ()]
748+ with self .assertWarnsRegex (DeprecationWarning , "Use the filter argument" ) as cm :
749+ tar .extractall (DIR , directories )
750+ # check that the stacklevel of the deprecation warning is correct:
751+ self .assertEqual (cm .filename , __file__ )
752+
753+ def test_deprecation_if_no_filter_passed_to_extract (self ):
754+ dirtype = "ustar/dirtype"
755+ DIR = pathlib .Path (TEMPDIR ) / "extractall"
756+ with (
757+ os_helper .temp_dir (DIR ),
758+ tarfile .open (tarname , encoding = "iso8859-1" ) as tar
759+ ):
760+ tarinfo = tar .getmember (dirtype )
761+ with self .assertWarnsRegex (DeprecationWarning , "Use the filter argument" ) as cm :
762+ tar .extract (tarinfo , path = DIR )
763+ # check that the stacklevel of the deprecation warning is correct:
764+ self .assertEqual (cm .filename , __file__ )
765+
741766 def test_extractall_pathlike_name (self ):
742767 DIR = pathlib .Path (TEMPDIR ) / "extractall"
743768 with os_helper .temp_dir (DIR ), \
0 commit comments