@@ -2042,23 +2042,31 @@ def test_make_zipfile_in_curdir(self):
20422042 self .assertEqual (make_archive ('test' , 'zip' ), 'test.zip' )
20432043 self .assertTrue (os .path .isfile ('test.zip' ))
20442044
2045- @support .requires_zlib ()
2046- def test_make_archive_accepts_pathlike (self ):
2047- tmpdir = self .mkdtemp ()
2048- with os_helper .change_cwd (tmpdir ), no_chdir :
2049- # Test path-like base_name without root_dir and base_dir
2050- base_name = FakePath (os .path .join (tmpdir , 'archive' ))
2051- res = make_archive (base_name , 'zip' )
2052- self .assertEqual (res , os .path .join (tmpdir , 'archive.zip' ))
2053- self .assertTrue (os .path .isfile (res ))
2054-
2055- # Test with path-like base_name, root_dir, and base_dir
2056- root_dir , base_dir = self ._create_files ()
2057- base_name = FakePath (os .path .join (tmpdir , 'archive2' ))
2058- res = make_archive (
2059- base_name , 'zip' , FakePath (root_dir ), FakePath (base_dir ))
2060- self .assertEqual (res , os .path .join (tmpdir , 'archive2.zip' ))
2061- self .assertTrue (os .path .isfile (res ))
2045+ def test_make_archive_pathlike_cwd_default (self ):
2046+ called_args = []
2047+ def archiver (base_name , base_dir , ** kw ):
2048+ called_args .append ((base_name , kw .get ('root_dir' )))
2049+
2050+ register_archive_format ('xxx' , archiver , [], 'xxx file' )
2051+ self .addCleanup (unregister_archive_format , 'xxx' )
2052+ with no_chdir :
2053+ make_archive (FakePath ('basename' ), 'xxx' )
2054+ self .assertEqual (called_args , [('basename' , None )])
2055+
2056+ def test_make_archive_pathlike_cwd_supports_root_dir (self ):
2057+ root_dir = self .mkdtemp ()
2058+ called_args = []
2059+ def archiver (base_name , base_dir , ** kw ):
2060+ called_args .append ((base_name , base_dir , kw .get ('root_dir' )))
2061+ archiver .supports_root_dir = True
2062+
2063+ register_archive_format ('xxx' , archiver , [], 'xxx file' )
2064+ self .addCleanup (unregister_archive_format , 'xxx' )
2065+ with no_chdir :
2066+ make_archive (FakePath ('basename' ), 'xxx' ,
2067+ root_dir = FakePath (root_dir ),
2068+ base_dir = FakePath ('basedir' ))
2069+ self .assertEqual (called_args , [('basename' , 'basedir' , root_dir )])
20622070
20632071 def test_register_archive_format (self ):
20642072
0 commit comments