Buckets:
ktongue/docker_container / simsite /venv /lib /python3.14 /site-packages /matplotlib /tests /test_matplotlib.py
| import os | |
| import subprocess | |
| import sys | |
| from unittest.mock import patch | |
| import pytest | |
| import matplotlib | |
| from matplotlib.testing import subprocess_run_for_testing | |
| def test_parse_to_version_info(version_str, version_tuple): | |
| assert matplotlib._parse_to_version_info(version_str) == version_tuple | |
| def test_tmpconfigdir_warning(tmp_path): | |
| """Test that a warning is emitted if a temporary configdir must be used.""" | |
| mode = os.stat(tmp_path).st_mode | |
| try: | |
| os.chmod(tmp_path, 0) | |
| proc = subprocess_run_for_testing( | |
| [sys.executable, "-c", "import matplotlib"], | |
| env={**os.environ, "MPLCONFIGDIR": str(tmp_path)}, | |
| stderr=subprocess.PIPE, text=True, check=True) | |
| assert "set the MPLCONFIGDIR" in proc.stderr | |
| finally: | |
| os.chmod(tmp_path, mode) | |
| def test_importable_with_no_home(tmp_path): | |
| subprocess_run_for_testing( | |
| [sys.executable, "-c", | |
| "import pathlib; pathlib.Path.home = lambda *args: 1/0; " | |
| "import matplotlib.pyplot"], | |
| env={**os.environ, "MPLCONFIGDIR": str(tmp_path)}, check=True) | |
| def test_use_doc_standard_backends(): | |
| """ | |
| Test that the standard backends mentioned in the docstring of | |
| matplotlib.use() are the same as in matplotlib.rcsetup. | |
| """ | |
| def parse(key): | |
| backends = [] | |
| for line in matplotlib.use.__doc__.split(key)[1].split('\n'): | |
| if not line.strip(): | |
| break | |
| backends += [e.strip().lower() for e in line.split(',') if e] | |
| return backends | |
| from matplotlib.backends import BackendFilter, backend_registry | |
| assert (set(parse('- interactive backends:\n')) == | |
| set(backend_registry.list_builtin(BackendFilter.INTERACTIVE))) | |
| assert (set(parse('- non-interactive backends:\n')) == | |
| set(backend_registry.list_builtin(BackendFilter.NON_INTERACTIVE))) | |
| def test_importable_with__OO(): | |
| """ | |
| When using -OO or export PYTHONOPTIMIZE=2, docstrings are discarded, | |
| this simple test may prevent something like issue #17970. | |
| """ | |
| program = ( | |
| "import matplotlib as mpl; " | |
| "import matplotlib.pyplot as plt; " | |
| "import matplotlib.cbook as cbook; " | |
| "import matplotlib.patches as mpatches" | |
| ) | |
| subprocess_run_for_testing( | |
| [sys.executable, "-OO", "-c", program], | |
| env={**os.environ, "MPLBACKEND": ""}, check=True | |
| ) | |
| def test_get_executable_info_timeout(mock_check_output): | |
| """ | |
| Test that _get_executable_info raises ExecutableNotFoundError if the | |
| command times out. | |
| """ | |
| mock_check_output.side_effect = subprocess.TimeoutExpired(cmd=['mock'], timeout=30) | |
| with pytest.raises(matplotlib.ExecutableNotFoundError, match='Timed out'): | |
| matplotlib._get_executable_info.__wrapped__('inkscape') | |
Xet Storage Details
- Size:
- 3.37 kB
- Xet hash:
- 8ec59acdfaa88700dff35d280a2b95a9208a12688a1525a4052fdc12d85a22b8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.