1010def setUp (self ):
1111 dj .config ['stores' ] = stores_config
1212
13+
1314def test_path_match (store = "repo" ):
1415 """ test file path matches and empty file"""
1516 ext = schema .external [store ]
@@ -22,7 +23,7 @@ def test_path_match(store="repo"):
2223 open (str (managed_file ), 'a' ).close ()
2324
2425 # put the file
25- uuid = ext .upload_filepath (managed_file )
26+ uuid = ext .upload_filepath (str ( managed_file ) )
2627
2728 #remove
2829 managed_file .unlink ()
@@ -35,12 +36,13 @@ def test_path_match(store="repo"):
3536
3637 # # Download the file and check its contents.
3738 restored_path , checksum = ext .download_filepath (uuid )
38- assert_equal (restored_path , managed_file )
39- assert_equal (checksum , dj .hash .uuid_from_file (managed_file ))
39+ assert_equal (restored_path , str ( managed_file ) )
40+ assert_equal (checksum , dj .hash .uuid_from_file (str ( managed_file ) ))
4041
4142 # cleanup
4243 ext .delete (delete_external_files = True )
4344
45+
4446def test_filepath (store = "repo" ):
4547 """ test file management """
4648 ext = schema .external [store ]
@@ -56,8 +58,8 @@ def test_filepath(store="repo"):
5658 f .write (data )
5759
5860 # put the same file twice to ensure storing once
59- uuid1 = ext .upload_filepath (managed_file )
60- uuid2 = ext .upload_filepath (managed_file ) # no duplication should arise if file is the same
61+ uuid1 = ext .upload_filepath (str ( managed_file ) )
62+ uuid2 = ext .upload_filepath (str ( managed_file ) ) # no duplication should arise if file is the same
6163 assert_equal (uuid1 , uuid2 )
6264
6365 # remove to ensure downloading
@@ -67,8 +69,8 @@ def test_filepath(store="repo"):
6769 # Download the file and check its contents. Repeat causes no download from remote
6870 for _ in 1 , 2 :
6971 restored_path , checksum = ext .download_filepath (uuid1 )
70- assert_equal (restored_path , managed_file )
71- assert_equal (checksum , dj .hash .uuid_from_file (managed_file ))
72+ assert_equal (restored_path , str ( managed_file ) )
73+ assert_equal (checksum , dj .hash .uuid_from_file (str ( managed_file ) ))
7274
7375 # verify same data
7476 with managed_file .open ('rb' ) as f :
@@ -92,8 +94,8 @@ def test_duplicate_upload(store="repo"):
9294 managed_file .parent .mkdir (parents = True , exist_ok = True )
9395 with managed_file .open ('wb' ) as f :
9496 f .write (os .urandom (300 ))
95- ext .upload_filepath (managed_file )
96- ext .upload_filepath (managed_file ) # this is fine because the file is the same
97+ ext .upload_filepath (str ( managed_file ) )
98+ ext .upload_filepath (str ( managed_file ) ) # this is fine because the file is the same
9799
98100
99101def test_duplicate_upload_s3 ():
@@ -110,10 +112,10 @@ def test_duplicate_error(store="repo"):
110112 managed_file .parent .mkdir (parents = True , exist_ok = True )
111113 with managed_file .open ('wb' ) as f :
112114 f .write (os .urandom (300 ))
113- ext .upload_filepath (managed_file )
115+ ext .upload_filepath (str ( managed_file ) )
114116 with managed_file .open ('wb' ) as f :
115117 f .write (os .urandom (300 ))
116- ext .upload_filepath (managed_file ) # this should raise exception because the file has changed
118+ ext .upload_filepath (str ( managed_file ) ) # this should raise exception because the file has changed
117119
118120
119121def test_duplicate_error_s3 ():
@@ -135,7 +137,7 @@ def test_filepath_class(table=Filepath(), store="repo"):
135137 assert_equal (data , contents )
136138
137139 # upload file into shared repo
138- table .insert1 ((1 , managed_file ))
140+ table .insert1 ((1 , str ( managed_file ) ))
139141
140142 # remove file locally
141143 managed_file .unlink ()
@@ -187,7 +189,7 @@ def test_filepath_cleanup(table=Filepath(), store="repo"):
187189 managed_file .parent .mkdir (parents = True , exist_ok = True )
188190 with managed_file .open ('wb' ) as f :
189191 f .write (contents ) # same in all files
190- table .insert1 ((i , managed_file ))
192+ table .insert1 ((i , str ( managed_file ) ))
191193 assert_equal (len (table ), n )
192194
193195 ext = schema .external [store ]
@@ -235,7 +237,7 @@ def test_return_string(table=Filepath(), store="repo"):
235237 assert_equal (data , contents )
236238
237239 # upload file into shared repo
238- table .insert1 ((138 , managed_file ))
240+ table .insert1 ((138 , str ( managed_file ) ))
239241
240242 # remove file locally
241243 managed_file .unlink ()
0 commit comments