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