File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 1+ import atexit
12import os
23import shutil
4+ from contextlib import ExitStack
5+ from importlib .resources import as_file , files
36from pathlib import Path
47
58import pytest
6- from pkg_resources import Requirement , ResolutionError , resource_filename
79
810
911def get_path (filename : str ) -> Path :
12+ """Get the filepath for a given test file."""
1013 # normalizing path depending on OS or else it will cause problem when joining path
1114 filename = os .path .normpath (filename )
1215 filepath = None
1316 try :
14- filepath = resource_filename (Requirement .parse ("cwl-utils" ), filename )
15- except ResolutionError :
17+ file_manager = ExitStack ()
18+ atexit .register (file_manager .close )
19+ traversable = files ("cwl-utils" ) / filename
20+ filepath = file_manager .enter_context (as_file (traversable ))
21+ except ModuleNotFoundError :
1622 pass
17- if not filepath or not os . path . isfile ( filepath ):
18- filepath = os . path . join (os .path .dirname (__file__ ), os .pardir , filename )
19- return Path ( filepath ) .resolve ()
23+ if not filepath or not filepath . is_file ( ):
24+ filepath = Path (os .path .dirname (__file__ ), os .pardir , filename )
25+ return filepath .resolve ()
2026
2127
2228def get_data (filename : str ) -> str :
You can’t perform that action at this time.
0 commit comments