Show More
@@ -111,7 +111,7 b' def display(' | |||||
111 | display_id=None, |
|
111 | display_id=None, | |
112 | raw=False, |
|
112 | raw=False, | |
113 | clear=False, |
|
113 | clear=False, | |
114 | **kwargs |
|
114 | **kwargs, | |
115 | ): |
|
115 | ): | |
116 | """Display a Python object in all frontends. |
|
116 | """Display a Python object in all frontends. | |
117 |
|
117 |
@@ -268,3 +268,87 b' def test_figure_no_canvas():' | |||||
268 | fig = Figure() |
|
268 | fig = Figure() | |
269 | fig.canvas = None |
|
269 | fig.canvas = None | |
270 | pt.print_figure(fig) |
|
270 | pt.print_figure(fig) | |
|
271 | ||||
|
272 | ||||
|
273 | @pytest.mark.parametrize( | |||
|
274 | "name, expected_gui, expected_backend", | |||
|
275 | [ | |||
|
276 | # name is gui | |||
|
277 | ("gtk3", "gtk3", "gtk3agg"), | |||
|
278 | ("gtk4", "gtk4", "gtk4agg"), | |||
|
279 | ("headless", "headless", "agg"), | |||
|
280 | ("osx", "osx", "macosx"), | |||
|
281 | ("qt", "qt", "qtagg"), | |||
|
282 | ("qt5", "qt5", "qt5agg"), | |||
|
283 | ("qt6", "qt6", "qt6agg"), | |||
|
284 | ("tk", "tk", "tkagg"), | |||
|
285 | ("wx", "wx", "wxagg"), | |||
|
286 | # name is backend | |||
|
287 | ("agg", None, "agg"), | |||
|
288 | ("cairo", None, "cairo"), | |||
|
289 | ("pdf", None, "pdf"), | |||
|
290 | ("ps", None, "ps"), | |||
|
291 | ("svg", None, "svg"), | |||
|
292 | ("template", None, "template"), | |||
|
293 | ("gtk3agg", "gtk3", "gtk3agg"), | |||
|
294 | ("gtk3cairo", "gtk3", "gtk3cairo"), | |||
|
295 | ("gtk4agg", "gtk4", "gtk4agg"), | |||
|
296 | ("gtk4cairo", "gtk4", "gtk4cairo"), | |||
|
297 | ("macosx", "osx", "macosx"), | |||
|
298 | ("nbagg", "nbagg", "nbagg"), | |||
|
299 | ("notebook", "nbagg", "notebook"), | |||
|
300 | ("qtagg", "qt", "qtagg"), | |||
|
301 | ("qtcairo", "qt", "qtcairo"), | |||
|
302 | ("qt5agg", "qt5", "qt5agg"), | |||
|
303 | ("qt5cairo", "qt5", "qt5cairo"), | |||
|
304 | ("qt6agg", "qt", "qt6agg"), | |||
|
305 | ("qt6cairo", "qt", "qt6cairo"), | |||
|
306 | ("tkagg", "tk", "tkagg"), | |||
|
307 | ("tkcairo", "tk", "tkcairo"), | |||
|
308 | ("webagg", "webagg", "webagg"), | |||
|
309 | ("wxagg", "wx", "wxagg"), | |||
|
310 | ("wxcairo", "wx", "wxcairo"), | |||
|
311 | ], | |||
|
312 | ) | |||
|
313 | def test_backend_builtin(name, expected_gui, expected_backend): | |||
|
314 | # Test correct identification of Matplotlib built-in backends without importing and using them, | |||
|
315 | # otherwise we would need to ensure all the complex dependencies such as windowing toolkits are | |||
|
316 | # installed. | |||
|
317 | ||||
|
318 | mpl_manages_backends = pt._matplotlib_manages_backends() | |||
|
319 | if not mpl_manages_backends: | |||
|
320 | # Backends not supported before _matplotlib_manages_backends or supported | |||
|
321 | # but with different expected_gui or expected_backend. | |||
|
322 | if ( | |||
|
323 | name.endswith("agg") | |||
|
324 | or name.endswith("cairo") | |||
|
325 | or name in ("headless", "macosx", "pdf", "ps", "svg", "template") | |||
|
326 | ): | |||
|
327 | pytest.skip() | |||
|
328 | elif name == "qt6": | |||
|
329 | expected_backend = "qtagg" | |||
|
330 | elif name == "notebook": | |||
|
331 | expected_backend, expected_gui = expected_gui, expected_backend | |||
|
332 | ||||
|
333 | gui, backend = pt.find_gui_and_backend(name) | |||
|
334 | if not mpl_manages_backends: | |||
|
335 | gui = gui.lower() if gui else None | |||
|
336 | backend = backend.lower() if backend else None | |||
|
337 | assert gui == expected_gui | |||
|
338 | assert backend == expected_backend | |||
|
339 | ||||
|
340 | ||||
|
341 | def test_backend_entry_point(): | |||
|
342 | gui, backend = pt.find_gui_and_backend("inline") | |||
|
343 | assert gui is None | |||
|
344 | expected_backend = ( | |||
|
345 | "inline" | |||
|
346 | if pt._matplotlib_manages_backends() | |||
|
347 | else "module://matplotlib_inline.backend_inline" | |||
|
348 | ) | |||
|
349 | assert backend == expected_backend | |||
|
350 | ||||
|
351 | ||||
|
352 | def test_backend_unknown(): | |||
|
353 | with pytest.raises(RuntimeError if pt._matplotlib_manages_backends() else KeyError): | |||
|
354 | pt.find_gui_and_backend("name-does-not-exist") |
@@ -197,7 +197,7 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||||
197 | dummy=None, |
|
197 | dummy=None, | |
198 | stack_depth=1, |
|
198 | stack_depth=1, | |
199 | compile_flags=None, |
|
199 | compile_flags=None, | |
200 | **kw |
|
200 | **kw, | |
201 | ): |
|
201 | ): | |
202 | """Activate the interactive interpreter. |
|
202 | """Activate the interactive interpreter. | |
203 |
|
203 |
General Comments 0
You need to be logged in to leave comments.
Login now