Skip to content
Merged
Changes from 1 commit
Commits
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
Add test capturing missed expectation when the path appears in the re…
…sultant tarfile.
  • Loading branch information
jaraco committed Sep 7, 2020
commit 394888035a21a21dc6584527a06d903f0e83cdc6
14 changes: 13 additions & 1 deletion Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,12 +1416,15 @@ def write(self, data):
pax_headers={'non': 'empty'})
self.assertFalse(f.closed)


class GzipWriteTest(GzipTest, WriteTest):
pass


class Bz2WriteTest(Bz2Test, WriteTest):
pass


class LzmaWriteTest(LzmaTest, WriteTest):
pass

Expand Down Expand Up @@ -1464,8 +1467,17 @@ def test_file_mode(self):
finally:
os.umask(original_umask)


class GzipStreamWriteTest(GzipTest, StreamWriteTest):
pass
def test_source_directory_not_leaked(self):
"""
Ensure the source directory is not included in the tar header
per bpo-41316.
"""
tarfile.open(tmpname, self.mode).close()
payload = pathlib.Path(tmpname).read_text(encoding='latin-1')
assert os.path.dirname(tmpname) not in payload


class Bz2StreamWriteTest(Bz2Test, StreamWriteTest):
decompressor = bz2.BZ2Decompressor if bz2 else None
Expand Down