()
| 201 | |
| 202 | |
| 203 | def test_register_command_ep(): |
| 204 | from dask.cli import _register_command_ep |
| 205 | |
| 206 | bad_ep = importlib_metadata.EntryPoint( |
| 207 | name="bad", |
| 208 | value="dask.tests.test_cli:bad_command", |
| 209 | group="dask_cli", |
| 210 | ) |
| 211 | |
| 212 | good_ep = importlib_metadata.EntryPoint( |
| 213 | name="good", |
| 214 | value="dask.tests.test_cli:good_command", |
| 215 | group="dask_cli", |
| 216 | ) |
| 217 | |
| 218 | class ErrorEP: |
| 219 | @property |
| 220 | def name(self): |
| 221 | return "foo" |
| 222 | |
| 223 | def load(self): |
| 224 | raise ImportError("Entrypoint could not be imported") |
| 225 | |
| 226 | with pytest.warns(UserWarning, match="must be instances of"): |
| 227 | _register_command_ep(dummy_cli, bad_ep) |
| 228 | |
| 229 | with pytest.warns(UserWarning, match="exception occurred"): |
| 230 | _register_command_ep(dummy_cli, ErrorEP()) |
| 231 | |
| 232 | _register_command_ep(dummy_cli, good_ep) |
| 233 | assert "good" in dummy_cli.commands |
| 234 | assert dummy_cli.commands["good"] is good_command |
| 235 | |
| 236 | |
| 237 | @click.group() |
nothing calls this directly
no test coverage detected