|
|
@@ -43,12 +43,13 @@ FILENAMES = [ |
|
|
|
#'álért.txt', |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
def make_temp_files(): |
|
|
|
print TMPDIR |
|
|
|
if not os.path.exists(ZIPPATH): |
|
|
|
for name in FILENAMES: |
|
|
|
file(os.path.join(TMPDIR, name), 'w').write(''.join(random.sample(string.printable, 10))) |
|
|
|
|
|
|
|
|
|
|
|
def make_temp_archive(): |
|
|
|
if not os.access(ZIPCMD, os.X_OK): |
|
|
|
raise AssertionError('Cannot execute %s.' % ZIPCMD) |
|
|
@@ -56,7 +57,7 @@ def make_temp_archive(): |
|
|
|
make_temp_files() |
|
|
|
cmd.extend(FILENAMES) |
|
|
|
os.chdir(TMPDIR) |
|
|
|
subprocess.call(cmd) |
|
|
|
subprocess.call(cmd, stdout=subprocess.PIPE) |
|
|
|
|
|
|
|
|
|
|
|
class TestIsArchiveName(unittest.TestCase): |
|
|
@@ -175,15 +176,18 @@ class TestZipWrite(unittest.TestCase): |
|
|
|
|
|
|
|
f = file(ZIPPATH, mode='w') |
|
|
|
z = ZipFile(f, 'w') |
|
|
|
z.writepath('/home/user/testpath', pathname='/testdir', folder=True) |
|
|
|
z.writepath(None, pathname='/testdir', folder=True) |
|
|
|
z.writepath(None, pathname='/testdir/testinside', folder=True) |
|
|
|
z.close() |
|
|
|
f.close() |
|
|
|
|
|
|
|
f = file(ZIPPATH, mode='r') |
|
|
|
z = ZipFile(f, 'r') |
|
|
|
|
|
|
|
assert len(z.entries) == 1 |
|
|
|
assert z.entries[0].isdir() |
|
|
|
entries = z.infolist() |
|
|
|
|
|
|
|
assert len(entries) == 2 |
|
|
|
assert entries[0].isdir() |
|
|
|
z.close() |
|
|
|
f.close() |
|
|
|
|
|
|
|