Skip to content

Commit f8dea65

Browse files
committed
Add tests for exclude files
1 parent 5dbbb5b commit f8dea65

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/unit/test_files.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pickle
2+
import tarfile
23
import unittest
34
from pathlib import Path
45

@@ -94,6 +95,7 @@ def test_remove(self):
9495

9596
def test_compress(self):
9697
self.directory.write(file_name="test1.txt", content="something")
98+
self.directory.write(file_name="test2.txt", content="something")
9799
self.directory.compress()
98100
self.assertTrue(
99101
Path("test.tar.gz").exists(),
@@ -102,6 +104,12 @@ def test_compress(self):
102104
# Test that compressing again does not overwrite the existing file
103105
self.directory.compress()
104106
self.assertTrue(Path("test.tar.gz").exists())
107+
Path("test.tar.gz").unlink()
108+
self.directory.compress(exclude_files=["test1.txt"])
109+
with tarfile.open("test.tar.gz", "r:*") as f:
110+
content = [name for name in f.getnames()]
111+
self.assertNotIn("test1.txt", content, msg="Excluded file should not be in archive")
112+
self.assertIn("test2.txt", content, msg="Included file should be in archive")
105113

106114

107115
if __name__ == "__main__":

0 commit comments

Comments
 (0)