Conditions | 6 |
Total Lines | 38 |
Code Lines | 30 |
Lines | 38 |
Ratio | 100 % |
Changes | 0 |
1 | import os |
||
10 | def test_tardir(self): |
||
11 | tempfile = '/Users/Shared/kasdkfasdf.txt' |
||
12 | with open(tempfile, 'w') as wfd: |
||
13 | wfd.write(tempfile) |
||
14 | with open(tempfile, 'r') as rfd1, open(tempfile, 'r') as rfd2: |
||
15 | paths = { |
||
16 | 'abc': 'abc abc abc', |
||
17 | 'kbs': { |
||
18 | 'haha': {}, |
||
19 | 'yoyo': { |
||
20 | 'haha': rfd1 |
||
21 | } |
||
22 | }, |
||
23 | 'abcd': { |
||
24 | 'kbs': rfd2 |
||
25 | }, |
||
26 | } |
||
27 | with tardir('/Users/Shared/haha.tar.gz', **paths) as tarfile: |
||
28 | self.assertTrue(os.path.exists(tarfile.filepath)) |
||
29 | self.assertFalse(os.path.exists(tarfile.filepath)) |
||
30 | with open(tempfile, 'r') as rfd1, open(tempfile, 'r') as rfd2: |
||
31 | paths = { |
||
32 | 'abc': 'abc abc abc', |
||
33 | 'kbs': { |
||
34 | 'haha': {}, |
||
35 | 'yoyo': { |
||
36 | 'haha': rfd1 |
||
37 | } |
||
38 | }, |
||
39 | 'abcd': { |
||
40 | 'kbs': rfd2 |
||
41 | }, |
||
42 | } |
||
43 | with tardir('/Users/Shared/haha.zip', **paths, mode='w:zip', withdir=True) as tarfile: |
||
44 | self.assertTrue(os.path.exists(tarfile.filepath)) |
||
45 | sleep(10) |
||
46 | self.assertFalse(os.path.exists(tarfile.filepath)) |
||
47 | os.remove(tempfile) |
||
48 | |||
52 |