1
1
from unittest import mock
2
2
3
+ import pytest
4
+ from importlib_metadata import EntryPoint
5
+
6
+ from xarray .backends import common , plugins
7
+
3
8
try :
4
9
import importlib .metadata as importlib_metadata
5
10
except ImportError :
6
11
# if the fallback library is missing, we are doomed.
7
12
import importlib_metadata as importlib_metadata
8
13
9
- from importlib_metadata import EntryPoint
10
-
11
- import pytest
12
-
13
- from xarray .backends import common , plugins
14
-
15
14
16
15
class DummyBackendEntrypointArgs (common .BackendEntrypoint ):
17
16
def open_dataset (filename_or_obj , * args ):
@@ -55,7 +54,9 @@ def test_remove_duplicates(dummy_duplicated_entrypoints) -> None:
55
54
56
55
def test_broken_plugin () -> None :
57
56
broken_backend = EntryPoint (
58
- "broken_backend" , "xarray.tests.test_plugins:backend_1" , "xarray.backends" ,
57
+ "broken_backend" ,
58
+ "xarray.tests.test_plugins:backend_1" ,
59
+ "xarray.backends" ,
59
60
)
60
61
with pytest .warns (RuntimeWarning ) as record :
61
62
_ = plugins .build_engines ([broken_backend ])
@@ -80,7 +81,7 @@ def test_remove_duplicates_warnings(dummy_duplicated_entrypoints) -> None:
80
81
def test_backends_dict_from_pkg () -> None :
81
82
specs = [
82
83
["engine1" , "xarray.tests.test_plugins:backend_1" , "xarray.backends" ],
83
- ["engine2" , "xarray.tests.test_plugins:backend_2" , "xarray.backends" ]
84
+ ["engine2" , "xarray.tests.test_plugins:backend_2" , "xarray.backends" ],
84
85
]
85
86
entrypoints = [EntryPoint (name , value , group ) for name , value , group in specs ]
86
87
engines = plugins .backends_dict_from_pkg (entrypoints )
@@ -144,12 +145,8 @@ def test_build_engines() -> None:
144
145
)
145
146
def test_build_engines_sorted () -> None :
146
147
dummy_pkg_entrypoints = [
147
- EntryPoint (
148
- "dummy2" , "xarray.tests.test_plugins:backend_1" , "xarray.backends"
149
- ),
150
- EntryPoint (
151
- "dummy1" , "xarray.tests.test_plugins:backend_1" , "xarray.backends"
152
- ),
148
+ EntryPoint ("dummy2" , "xarray.tests.test_plugins:backend_1" , "xarray.backends" ),
149
+ EntryPoint ("dummy1" , "xarray.tests.test_plugins:backend_1" , "xarray.backends" ),
153
150
]
154
151
backend_entrypoints = plugins .build_engines (dummy_pkg_entrypoints )
155
152
backend_entrypoints = list (backend_entrypoints )
0 commit comments