Skip to content

Commit 1b41792

Browse files
committed
-
1 parent ca737be commit 1b41792

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

python_toolbox/zip_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def unzip_in_memory(zip_archive):
7373
compression=zip_module.ZIP_DEFLATED) as zip_file:
7474
assert isinstance(zip_file, zip_module.ZipFile)
7575
return tuple((file_name, zip_file.read(file_name)) for file_name in
76-
zip_file.namelist)
76+
zip_file.namelist())
7777

7878

7979

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright 2009-2013 Ram Rachum.
2+
# This program is distributed under the MIT license.
3+
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1+
# Copyright 2009-2013 Ram Rachum.
2+
# This program is distributed under the MIT license.
3+
14
from __future__ import with_statement
25

3-
from python_toolbox import tracing_tools
6+
from python_toolbox import cute_testing
47

8+
from python_toolbox import zip_tools
59

6-
def my_function():
7-
''' '''
810

9-
def test():
11+
def test_zipping_in_memory():
1012
''' '''
13+
files = (
14+
('meow.txt', "I'm a cat."),
15+
('dog.txt', "I'm a dog."),
16+
('folder/binary.bin', ''.join(map(chr, xrange(256))))
17+
)
1118

12-
with tracing_tools.TempFunctionCallCounter(my_function) as \
13-
temp_function_call_counter:
14-
assert temp_function_call_counter.call_count == 0
15-
my_function()
16-
assert temp_function_call_counter.call_count == 1
17-
my_function()
18-
my_function()
19-
my_function()
20-
assert temp_function_call_counter.call_count == 4
21-
22-
assert temp_function_call_counter.call_count == 4
23-
my_function()
24-
assert temp_function_call_counter.call_count == 4
19+
zip_archive = zip_tools.zip_in_memory(files)
20+
assert isinstance(zip_archive, str)
21+
assert set(zip_tools.unzip_in_memory(zip_archive)) == set(files)
2522

0 commit comments

Comments
 (0)