File tree 1 file changed +5
-6
lines changed
Python_part_3_files/tests
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import zipfile
3
3
from zipfile import ZipFile
4
+ from .conftest import path_tmp , path_res
4
5
5
6
6
7
def test_create_and_add_archive ():
7
- path_tmp = os .path .dirname (os .path .abspath (__file__ )) + '/../tmp'
8
- path_res = os .path .dirname (os .path .abspath (__file__ )) + '/../resources'
9
8
file_dir = os .listdir (path_res )
10
9
11
- with zipfile .ZipFile (path_tmp + '/ test.zip' , mode = 'w' , \
10
+ with zipfile .ZipFile (os . path . join ( path_tmp , ' test.zip') , mode = 'w' , \
12
11
compression = zipfile .ZIP_DEFLATED ) as zf :
13
12
for file in file_dir :
14
13
add_file = os .path .join (path_res , file )
15
14
zf .write (add_file )
16
15
17
16
18
17
def test_read_archive ():
19
- path_res = os .path .dirname (os .path .abspath (__file__ )) + '/../resources'
20
- path_tmp = os .path .dirname (os .path .abspath (__file__ )) + '/../tmp'
21
- with ZipFile (path_tmp + '/test.zip' ) as zf :
18
+ with ZipFile (os .path .join (path_tmp , 'test.zip' )) as zf :
22
19
filenames = [os .path .basename (file ) for file in zf .namelist ()]
20
+ print (filenames )
21
+ print (os .listdir (path_res ))
23
22
assert filenames == os .listdir (path_res )
You can’t perform that action at this time.
0 commit comments