File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 1
1
import pickle
2
+ import tarfile
2
3
import unittest
3
4
from pathlib import Path
4
5
@@ -94,6 +95,7 @@ def test_remove(self):
94
95
95
96
def test_compress (self ):
96
97
self .directory .write (file_name = "test1.txt" , content = "something" )
98
+ self .directory .write (file_name = "test2.txt" , content = "something" )
97
99
self .directory .compress ()
98
100
self .assertTrue (
99
101
Path ("test.tar.gz" ).exists (),
@@ -102,6 +104,12 @@ def test_compress(self):
102
104
# Test that compressing again does not overwrite the existing file
103
105
self .directory .compress ()
104
106
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" )
105
113
106
114
107
115
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments