File tree Expand file tree Collapse file tree 3 files changed +18
-18
lines changed
test_python_toolbox/test_zip_tools Expand file tree Collapse file tree 3 files changed +18
-18
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1+ # Copyright 2009-2013 Ram Rachum.
2+ # This program is distributed under the MIT license.
3+
Original file line number Diff line number Diff line change 1+ # Copyright 2009-2013 Ram Rachum.
2+ # This program is distributed under the MIT license.
3+
14from __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
You can’t perform that action at this time.
0 commit comments