summaryrefslogtreecommitdiff
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 867eca42b6..a76ceb1d2a 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -290,6 +290,20 @@ class WriteTest(BaseTest):
else:
self.dst.addfile(tarinfo, f)
+ def test_add_self(self):
+ dstname = os.path.abspath(self.dstname)
+
+ self.assertEqual(self.dst.name, dstname, "archive name must be absolute")
+
+ self.dst.add(dstname)
+ self.assertEqual(self.dst.getnames(), [], "added the archive to itself")
+
+ cwd = os.getcwd()
+ os.chdir(dirname())
+ self.dst.add(dstname)
+ os.chdir(cwd)
+ self.assertEqual(self.dst.getnames(), [], "added the archive to itself")
+
class Write100Test(BaseTest):
# The name field in a tar header stores strings of at most 100 chars.