|
22 | 22 | ) |
23 | 23 |
|
24 | 24 | import junit_xml |
25 | | -import pkg_resources |
26 | 25 | import ruamel.yaml.scanner |
27 | 26 | import schema_salad.avro |
28 | 27 | import schema_salad.ref_resolver |
|
32 | 31 | from ruamel.yaml.scalarstring import ScalarString |
33 | 32 | from schema_salad.exceptions import ValidationException |
34 | 33 |
|
| 34 | +if sys.version_info >= (3, 9): |
| 35 | + from importlib.resources import as_file, files |
| 36 | +else: |
| 37 | + from importlib_resources import as_file, files |
| 38 | + |
35 | 39 | from cwltest import REQUIRED, UNSUPPORTED_FEATURE, logger, templock |
36 | 40 |
|
| 41 | +__all__ = ["files", "as_file"] |
| 42 | + |
37 | 43 |
|
38 | 44 | class CWLTestConfig: |
39 | 45 | """Store configuration values for cwltest.""" |
@@ -167,12 +173,11 @@ def load_and_validate_tests(path: str) -> Tuple[Any, Dict[str, Any]]: |
167 | 173 |
|
168 | 174 | This also processes $import directives. |
169 | 175 | """ |
170 | | - schema_resource = pkg_resources.resource_stream(__name__, "cwltest-schema.yml") |
171 | | - cache: Optional[Dict[str, Union[str, Graph, bool]]] = { |
172 | | - "https://w3id.org/cwl/cwltest/cwltest-schema.yml": schema_resource.read().decode( |
173 | | - "utf-8" |
174 | | - ) |
175 | | - } |
| 176 | + schema_resource = files("cwltest").joinpath("cwltest-schema.yml") |
| 177 | + with schema_resource.open("r", encoding="utf-8") as fp: |
| 178 | + cache: Optional[Dict[str, Union[str, Graph, bool]]] = { |
| 179 | + "https://w3id.org/cwl/cwltest/cwltest-schema.yml": fp.read() |
| 180 | + } |
176 | 181 | ( |
177 | 182 | document_loader, |
178 | 183 | avsc_names, |
|
0 commit comments