-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
/
Copy pathtest_backend.py
33 lines (25 loc) · 1.12 KB
/
test_backend.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pytest
import pandas
def test_matplotlib_backend_error():
msg = ('matplotlib is required for plotting when the default backend '
'"matplotlib" is selected.')
try:
import matplotlib # noqa
except ImportError:
with pytest.raises(ImportError, match=msg):
pandas.set_option('plotting.backend', 'matplotlib')
def test_backend_is_not_module():
msg = ('"not_an_existing_module" does not seem to be an installed module. '
'A pandas plotting backend must be a module that can be imported')
with pytest.raises(ValueError, match=msg):
pandas.set_option('plotting.backend', 'not_an_existing_module')
def test_backend_is_correct(monkeypatch):
monkeypatch.setattr('pandas.core.config_init.importlib.import_module',
lambda name: None)
pandas.set_option('plotting.backend', 'correct_backend')
assert pandas.get_option('plotting.backend') == 'correct_backend'
# Restore backend for other tests (matplotlib can be not installed)
try:
pandas.set_option('plotting.backend', 'matplotlib')
except ImportError:
pass