|
@@ -43,12 +43,13 @@ FILENAMES = [ |
|
|
#'álért.txt', |
|
|
#'álért.txt', |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_temp_files(): |
|
|
def make_temp_files(): |
|
|
print TMPDIR |
|
|
|
|
|
if not os.path.exists(ZIPPATH): |
|
|
if not os.path.exists(ZIPPATH): |
|
|
for name in FILENAMES: |
|
|
for name in FILENAMES: |
|
|
file(os.path.join(TMPDIR, name), 'w').write(''.join(random.sample(string.printable, 10))) |
|
|
file(os.path.join(TMPDIR, name), 'w').write(''.join(random.sample(string.printable, 10))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_temp_archive(): |
|
|
def make_temp_archive(): |
|
|
if not os.access(ZIPCMD, os.X_OK): |
|
|
if not os.access(ZIPCMD, os.X_OK): |
|
|
raise AssertionError('Cannot execute %s.' % ZIPCMD) |
|
|
raise AssertionError('Cannot execute %s.' % ZIPCMD) |
|
@@ -56,7 +57,7 @@ def make_temp_archive(): |
|
|
make_temp_files() |
|
|
make_temp_files() |
|
|
cmd.extend(FILENAMES) |
|
|
cmd.extend(FILENAMES) |
|
|
os.chdir(TMPDIR) |
|
|
os.chdir(TMPDIR) |
|
|
subprocess.call(cmd) |
|
|
|
|
|
|
|
|
subprocess.call(cmd, stdout=subprocess.PIPE) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestIsArchiveName(unittest.TestCase): |
|
|
class TestIsArchiveName(unittest.TestCase): |
|
@@ -175,15 +176,18 @@ class TestZipWrite(unittest.TestCase): |
|
|
|
|
|
|
|
|
f = file(ZIPPATH, mode='w') |
|
|
f = file(ZIPPATH, mode='w') |
|
|
z = ZipFile(f, '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() |
|
|
z.close() |
|
|
f.close() |
|
|
f.close() |
|
|
|
|
|
|
|
|
f = file(ZIPPATH, mode='r') |
|
|
f = file(ZIPPATH, mode='r') |
|
|
z = ZipFile(f, '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() |
|
|
z.close() |
|
|
f.close() |
|
|
f.close() |
|
|
|
|
|
|
|
|