1- from importlib .resources import path
1+ from importlib .resources import as_file , files
22from pathlib import Path
33from shutil import copy
44from tempfile import TemporaryDirectory
@@ -167,10 +167,10 @@ def test_list_directory(self):
167167 # call the function
168168 with TemporaryDirectory () as temp :
169169 # copy required files
170- with path ( "tests.resources.media" , "dummy.ass" ) as file :
170+ with as_file ( files ( "tests.resources.media" ). joinpath ( "dummy.ass" ) ) as file :
171171 copy (file , temp )
172172
173- with path ( "tests.resources.media" , "dummy.mkv" ) as file :
173+ with as_file ( files ( "tests.resources.media" ). joinpath ( "dummy.mkv" ) ) as file :
174174 copy (file , temp )
175175
176176 with self .assertLogs ("dakara_feeder.directory" , "DEBUG" ):
@@ -188,38 +188,40 @@ class GetMainTypeTestCase(TestCase):
188188
189189 def test_video (self ):
190190 """Test the common video files."""
191- with path ( "tests.resources.filetype" , "file.avi" ) as file :
191+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.avi" ) ) as file :
192192 self .assertEqual (get_main_type (file ), "video" )
193193
194- with path ( "tests.resources.filetype" , "file.mkv" ) as file :
194+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.mkv" ) ) as file :
195195 self .assertEqual (get_main_type (file ), "video" )
196196
197- with path ("tests.resources.filetype" , "file_upper.MKV" ) as file :
197+ with as_file (
198+ files ("tests.resources.filetype" ).joinpath ("file_upper.MKV" )
199+ ) as file :
198200 self .assertEqual (get_main_type (file ), "video" )
199201
200- with path ( "tests.resources.filetype" , "file.mp4" ) as file :
202+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.mp4" ) ) as file :
201203 self .assertEqual (get_main_type (file ), "video" )
202204
203205 def test_audio (self ):
204206 """Test the common audio files."""
205- with path ( "tests.resources.filetype" , "file.flac" ) as file :
207+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.flac" ) ) as file :
206208 self .assertEqual (get_main_type (file ), "audio" )
207209
208- with path ( "tests.resources.filetype" , "file.mp3" ) as file :
210+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.mp3" ) ) as file :
209211 self .assertEqual (get_main_type (file ), "audio" )
210212
211- with path ( "tests.resources.filetype" , "file.ogg" ) as file :
213+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.ogg" ) ) as file :
212214 self .assertEqual (get_main_type (file ), "audio" )
213215
214216 def test_subtitle (self ):
215217 """Test the common subtitles files."""
216- with path ( "tests.resources.filetype" , "file.ass" ) as file :
218+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.ass" ) ) as file :
217219 self .assertIsNone (get_main_type (file ))
218220
219- with path ( "tests.resources.filetype" , "file.ssa" ) as file :
221+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.ssa" ) ) as file :
220222 self .assertIsNone (get_main_type (file ))
221223
222- with path ( "tests.resources.filetype" , "file.srt" ) as file :
224+ with as_file ( files ( "tests.resources.filetype" ). joinpath ( "file.srt" ) ) as file :
223225 self .assertIsNone (get_main_type (file ))
224226
225227
0 commit comments