Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-74696: Pass root_dir to custom archivers which support it #94251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e5ebb8d
gh-74696: Pass root_dir to custom archivers which support it
serhiy-storchaka Jun 22, 2022
563b0f5
Update Doc/library/shutil.rst
serhiy-storchaka Jun 25, 2022
2190304
Merge branch 'main' into shutil-register_archive_format-supports_root…
merwok Sep 29, 2022
7dc8fb3
closes gh-97650: correct sphinx executable (gh-97651)
NoSuck Sep 29, 2022
679cf96
gh-96397: Document that attributes need not be identifiers (#96454)
jeff5 Sep 29, 2022
3c84af2
gh-96348: Deprecate the 3-arg signature of coroutine.throw and genera…
ofey404 Sep 30, 2022
8a0ad46
Use SyntaxError invalid range in tutorial introduction example (GH-93…
ehebert Sep 30, 2022
182755f
gh-97649: The Tools directory is no longer installed on Windows (GH-9…
zooba Sep 30, 2022
b1a9de0
gh-90989: Install Windows launcher per-user, and clarify some install…
zooba Sep 30, 2022
cc1e8e0
gh-94526: getpath_dirname() no longer encodes the path (#97645)
vstinner Sep 30, 2022
8fd0e86
bpo-35675: IDLE - separate config_key window and frame (#11427)
csabella Sep 30, 2022
d1d6b31
gh-87597: Document TimeoutExpired.stdout & .stderr types (#97685)
gpshead Sep 30, 2022
c6203f8
GH-96827: Don't touch closed loops from executor threads (#96837)
gvanrossum Sep 30, 2022
67851dc
GH-97592: Fix crash in C remove_done_callback due to evil code (#97660)
gvanrossum Sep 30, 2022
4c95e50
gh-90110: Update the c-analyzer Tool (gh-97695)
ericsnowcurrently Oct 1, 2022
fb39e7f
gh-90908: Document asyncio.Task.cancelling() and asyncio.Task.uncance…
ambv Oct 1, 2022
0bb7e71
Fix capitalization of Unix in documentation (#96913)
hawkinsw Oct 1, 2022
5ffc011
gh-95588: Drop the safety claim from `ast.literal_eval` docs. (#95919)
gpshead Oct 2, 2022
e401b65
gh-97591: In `Exception.__setstate__()` acquire strong references bef…
ofey404 Oct 2, 2022
879e866
gh-95975: Move except/*/finally ref labels to more precise locations …
CAM-Gerlach Oct 2, 2022
299dd41
gh-97607: Fix content parsing in the impl-detail reST directive (#97652)
CAM-Gerlach Oct 2, 2022
551b707
[docs] Update logging cookbook with recipe for using a logger like an…
vsajip Oct 2, 2022
b37f2cd
Refactor tests.
serhiy-storchaka Oct 2, 2022
bf58b11
Merge branch 'main' into shutil-register_archive_format-supports_root…
serhiy-storchaka Oct 2, 2022
9980c8c
Apply suggestions from code review
serhiy-storchaka Oct 4, 2022
5160cb7
fix markup
merwok Oct 4, 2022
701f896
Update Doc/whatsnew/3.12.rst
serhiy-storchaka Oct 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor tests.
  • Loading branch information
serhiy-storchaka committed Oct 2, 2022
commit b37f2cd5a9bf6a4bb89cbe6fa0ae5d744c978388
41 changes: 21 additions & 20 deletions 41 Lib/test/test_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,16 +1568,30 @@ def test_tarfile_root_owner(self):
finally:
archive.close()

def test_make_archive_cwd_default(self):
current_dir = os.getcwd()
def archiver(base_name, base_dir, **kw):
self.assertNotIn('root_dir', kw)
self.assertEqual(base_name, 'basename')
self.assertEqual(os.getcwd(), current_dir)
raise RuntimeError()

register_archive_format('xxx', archiver, [], 'xxx file')
try:
with no_chdir:
with self.assertRaises(RuntimeError):
make_archive('basename', 'xxx')
self.assertEqual(os.getcwd(), current_dir)
finally:
unregister_archive_format('xxx')

def test_make_archive_cwd(self):
current_dir = os.getcwd()
root_dir = self.mkdtemp()
def archiver(base_name, base_dir, **kw):
self.assertNotIn('root_dir', kw)
if root_dir is None:
self.assertEqual(base_name, 'basename')
self.assertEqual(os.getcwd(), current_dir)
else:
self.assertEqual(base_name, os.path.join(current_dir, 'basename'))
self.assertEqual(os.getcwd(), root_dir)
self.assertEqual(base_name, os.path.join(current_dir, 'basename'))
self.assertEqual(os.getcwd(), root_dir)
raise RuntimeError()
dirs = []
def _chdir(path):
Expand All @@ -1586,14 +1600,6 @@ def _chdir(path):

register_archive_format('xxx', archiver, [], 'xxx file')
try:
root_dir = None
with support.swap_attr(os, 'chdir', _chdir) as orig_chdir:
with self.assertRaises(RuntimeError):
make_archive('basename', 'xxx')
self.assertEqual(os.getcwd(), current_dir)
self.assertEqual(dirs, [])

root_dir = self.mkdtemp()
with support.swap_attr(os, 'chdir', _chdir) as orig_chdir:
with self.assertRaises(RuntimeError):
make_archive('basename', 'xxx', root_dir=root_dir)
Expand All @@ -1611,18 +1617,13 @@ def archiver(base_name, base_dir, **kw):
self.assertEqual(os.getcwd(), current_dir)
raise RuntimeError()
archiver.supports_root_dir = True
dirs = []
def _chdir(path):
dirs.append(path)
orig_chdir(path)

register_archive_format('xxx', archiver, [], 'xxx file')
try:
with support.swap_attr(os, 'chdir', _chdir) as orig_chdir:
with no_chdir:
with self.assertRaises(RuntimeError):
make_archive('basename', 'xxx', root_dir=root_dir)
self.assertEqual(os.getcwd(), current_dir)
self.assertEqual(dirs, [])
finally:
unregister_archive_format('xxx')

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.