From 9e7106b3a843b9268fab227ed20103037f57ff6f Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 17 May 2025 05:14:49 -0400 Subject: [PATCH] Move test data into a single subdirectory Consolidating these files make it easier to remove or restore them without having to track each one individually. --- .pre-commit-config.yaml | 2 +- .../{ => data}/Courier10PitchBT-Bold.pfb | Bin lib/matplotlib/tests/{ => data}/cmr10.pfb | Bin lib/matplotlib/tests/{ => data}/mpltest.ttf | Bin .../tests/{ => data}/test_inline_01.ipynb | 0 .../tests/{ => data}/test_nbagg_01.ipynb | 0 .../tests/{ => data}/tinypages/.gitignore | 0 .../tests/{ => data}/tinypages/README.md | 0 .../{ => data}/tinypages/_static/.gitignore | 0 .../{ => data}/tinypages/_static/README.txt | 0 .../tests/{ => data}/tinypages/conf.py | 0 .../{ => data}/tinypages/included_plot_21.rst | 0 .../tests/{ => data}/tinypages/index.rst | 0 .../{ => data}/tinypages/nestedpage/index.rst | 0 .../tinypages/nestedpage2/index.rst | 0 .../tests/{ => data}/tinypages/range4.py | 0 .../tests/{ => data}/tinypages/range6.py | 0 .../tests/{ => data}/tinypages/some_plots.rst | 0 lib/matplotlib/tests/meson.build | 9 ++---- lib/matplotlib/tests/test_backend_inline.py | 2 +- lib/matplotlib/tests/test_backend_nbagg.py | 2 +- lib/matplotlib/tests/test_backend_pdf.py | 2 +- lib/matplotlib/tests/test_font_manager.py | 6 ++-- lib/matplotlib/tests/test_mathtext.py | 2 +- lib/matplotlib/tests/test_sphinxext.py | 27 ++++++++---------- lib/matplotlib/tests/test_type1font.py | 6 ++-- 26 files changed, 25 insertions(+), 33 deletions(-) rename lib/matplotlib/tests/{ => data}/Courier10PitchBT-Bold.pfb (100%) rename lib/matplotlib/tests/{ => data}/cmr10.pfb (100%) rename lib/matplotlib/tests/{ => data}/mpltest.ttf (100%) rename lib/matplotlib/tests/{ => data}/test_inline_01.ipynb (100%) rename lib/matplotlib/tests/{ => data}/test_nbagg_01.ipynb (100%) rename lib/matplotlib/tests/{ => data}/tinypages/.gitignore (100%) rename lib/matplotlib/tests/{ => data}/tinypages/README.md (100%) rename lib/matplotlib/tests/{ => data}/tinypages/_static/.gitignore (100%) rename lib/matplotlib/tests/{ => data}/tinypages/_static/README.txt (100%) rename lib/matplotlib/tests/{ => data}/tinypages/conf.py (100%) rename lib/matplotlib/tests/{ => data}/tinypages/included_plot_21.rst (100%) rename lib/matplotlib/tests/{ => data}/tinypages/index.rst (100%) rename lib/matplotlib/tests/{ => data}/tinypages/nestedpage/index.rst (100%) rename lib/matplotlib/tests/{ => data}/tinypages/nestedpage2/index.rst (100%) rename lib/matplotlib/tests/{ => data}/tinypages/range4.py (100%) rename lib/matplotlib/tests/{ => data}/tinypages/range6.py (100%) rename lib/matplotlib/tests/{ => data}/tinypages/some_plots.rst (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index afcdc44c1b4a..86a9a0f45440 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ exclude: | doc/devel/gitwash| doc/users/prev| doc/api/prev| - lib/matplotlib/tests/tinypages + lib/matplotlib/tests/data/tinypages ) repos: - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/lib/matplotlib/tests/Courier10PitchBT-Bold.pfb b/lib/matplotlib/tests/data/Courier10PitchBT-Bold.pfb similarity index 100% rename from lib/matplotlib/tests/Courier10PitchBT-Bold.pfb rename to lib/matplotlib/tests/data/Courier10PitchBT-Bold.pfb diff --git a/lib/matplotlib/tests/cmr10.pfb b/lib/matplotlib/tests/data/cmr10.pfb similarity index 100% rename from lib/matplotlib/tests/cmr10.pfb rename to lib/matplotlib/tests/data/cmr10.pfb diff --git a/lib/matplotlib/tests/mpltest.ttf b/lib/matplotlib/tests/data/mpltest.ttf similarity index 100% rename from lib/matplotlib/tests/mpltest.ttf rename to lib/matplotlib/tests/data/mpltest.ttf diff --git a/lib/matplotlib/tests/test_inline_01.ipynb b/lib/matplotlib/tests/data/test_inline_01.ipynb similarity index 100% rename from lib/matplotlib/tests/test_inline_01.ipynb rename to lib/matplotlib/tests/data/test_inline_01.ipynb diff --git a/lib/matplotlib/tests/test_nbagg_01.ipynb b/lib/matplotlib/tests/data/test_nbagg_01.ipynb similarity index 100% rename from lib/matplotlib/tests/test_nbagg_01.ipynb rename to lib/matplotlib/tests/data/test_nbagg_01.ipynb diff --git a/lib/matplotlib/tests/tinypages/.gitignore b/lib/matplotlib/tests/data/tinypages/.gitignore similarity index 100% rename from lib/matplotlib/tests/tinypages/.gitignore rename to lib/matplotlib/tests/data/tinypages/.gitignore diff --git a/lib/matplotlib/tests/tinypages/README.md b/lib/matplotlib/tests/data/tinypages/README.md similarity index 100% rename from lib/matplotlib/tests/tinypages/README.md rename to lib/matplotlib/tests/data/tinypages/README.md diff --git a/lib/matplotlib/tests/tinypages/_static/.gitignore b/lib/matplotlib/tests/data/tinypages/_static/.gitignore similarity index 100% rename from lib/matplotlib/tests/tinypages/_static/.gitignore rename to lib/matplotlib/tests/data/tinypages/_static/.gitignore diff --git a/lib/matplotlib/tests/tinypages/_static/README.txt b/lib/matplotlib/tests/data/tinypages/_static/README.txt similarity index 100% rename from lib/matplotlib/tests/tinypages/_static/README.txt rename to lib/matplotlib/tests/data/tinypages/_static/README.txt diff --git a/lib/matplotlib/tests/tinypages/conf.py b/lib/matplotlib/tests/data/tinypages/conf.py similarity index 100% rename from lib/matplotlib/tests/tinypages/conf.py rename to lib/matplotlib/tests/data/tinypages/conf.py diff --git a/lib/matplotlib/tests/tinypages/included_plot_21.rst b/lib/matplotlib/tests/data/tinypages/included_plot_21.rst similarity index 100% rename from lib/matplotlib/tests/tinypages/included_plot_21.rst rename to lib/matplotlib/tests/data/tinypages/included_plot_21.rst diff --git a/lib/matplotlib/tests/tinypages/index.rst b/lib/matplotlib/tests/data/tinypages/index.rst similarity index 100% rename from lib/matplotlib/tests/tinypages/index.rst rename to lib/matplotlib/tests/data/tinypages/index.rst diff --git a/lib/matplotlib/tests/tinypages/nestedpage/index.rst b/lib/matplotlib/tests/data/tinypages/nestedpage/index.rst similarity index 100% rename from lib/matplotlib/tests/tinypages/nestedpage/index.rst rename to lib/matplotlib/tests/data/tinypages/nestedpage/index.rst diff --git a/lib/matplotlib/tests/tinypages/nestedpage2/index.rst b/lib/matplotlib/tests/data/tinypages/nestedpage2/index.rst similarity index 100% rename from lib/matplotlib/tests/tinypages/nestedpage2/index.rst rename to lib/matplotlib/tests/data/tinypages/nestedpage2/index.rst diff --git a/lib/matplotlib/tests/tinypages/range4.py b/lib/matplotlib/tests/data/tinypages/range4.py similarity index 100% rename from lib/matplotlib/tests/tinypages/range4.py rename to lib/matplotlib/tests/data/tinypages/range4.py diff --git a/lib/matplotlib/tests/tinypages/range6.py b/lib/matplotlib/tests/data/tinypages/range6.py similarity index 100% rename from lib/matplotlib/tests/tinypages/range6.py rename to lib/matplotlib/tests/data/tinypages/range6.py diff --git a/lib/matplotlib/tests/tinypages/some_plots.rst b/lib/matplotlib/tests/data/tinypages/some_plots.rst similarity index 100% rename from lib/matplotlib/tests/tinypages/some_plots.rst rename to lib/matplotlib/tests/data/tinypages/some_plots.rst diff --git a/lib/matplotlib/tests/meson.build b/lib/matplotlib/tests/meson.build index 05336496969f..48b97a1d4b3d 100644 --- a/lib/matplotlib/tests/meson.build +++ b/lib/matplotlib/tests/meson.build @@ -99,11 +99,6 @@ py3.install_sources(python_sources, install_data( 'README', - 'Courier10PitchBT-Bold.pfb', - 'cmr10.pfb', - 'mpltest.ttf', - 'test_nbagg_01.ipynb', - 'test_inline_01.ipynb', install_tag: 'tests', install_dir: py3.get_install_dir(subdir: 'matplotlib/tests/')) @@ -112,6 +107,6 @@ install_subdir( install_tag: 'tests', install_dir: py3.get_install_dir(subdir: 'matplotlib/tests')) install_subdir( - 'tinypages', + 'data', install_tag: 'tests', - install_dir: py3.get_install_dir(subdir: 'matplotlib/tests')) + install_dir: py3.get_install_dir(subdir: 'matplotlib/tests/')) diff --git a/lib/matplotlib/tests/test_backend_inline.py b/lib/matplotlib/tests/test_backend_inline.py index 6f0d67d51756..997e1e7186b1 100644 --- a/lib/matplotlib/tests/test_backend_inline.py +++ b/lib/matplotlib/tests/test_backend_inline.py @@ -13,7 +13,7 @@ def test_ipynb(): - nb_path = Path(__file__).parent / 'test_inline_01.ipynb' + nb_path = Path(__file__).parent / 'data/test_inline_01.ipynb' with TemporaryDirectory() as tmpdir: out_path = Path(tmpdir, "out.ipynb") diff --git a/lib/matplotlib/tests/test_backend_nbagg.py b/lib/matplotlib/tests/test_backend_nbagg.py index 23af88d95086..ccf74df20aab 100644 --- a/lib/matplotlib/tests/test_backend_nbagg.py +++ b/lib/matplotlib/tests/test_backend_nbagg.py @@ -14,7 +14,7 @@ def test_ipynb(): - nb_path = Path(__file__).parent / 'test_nbagg_01.ipynb' + nb_path = Path(__file__).parent / 'data/test_nbagg_01.ipynb' with TemporaryDirectory() as tmpdir: out_path = Path(tmpdir, "out.ipynb") diff --git a/lib/matplotlib/tests/test_backend_pdf.py b/lib/matplotlib/tests/test_backend_pdf.py index 60169a38c972..dc349e8dfa35 100644 --- a/lib/matplotlib/tests/test_backend_pdf.py +++ b/lib/matplotlib/tests/test_backend_pdf.py @@ -425,6 +425,6 @@ def test_truetype_conversion(recwarn): mpl.rcParams['pdf.fonttype'] = 3 fig, ax = plt.subplots() ax.text(0, 0, "ABCDE", - font=Path(__file__).with_name("mpltest.ttf"), fontsize=80) + font=Path(__file__).parent / "data/mpltest.ttf", fontsize=80) ax.set_xticks([]) ax.set_yticks([]) diff --git a/lib/matplotlib/tests/test_font_manager.py b/lib/matplotlib/tests/test_font_manager.py index d15b892b3eea..97ee8672b1d4 100644 --- a/lib/matplotlib/tests/test_font_manager.py +++ b/lib/matplotlib/tests/test_font_manager.py @@ -164,7 +164,7 @@ def test_user_fonts_linux(tmpdir, monkeypatch): # Prepare a temporary user font directory user_fonts_dir = tmpdir.join('fonts') user_fonts_dir.ensure(dir=True) - shutil.copyfile(Path(__file__).parent / font_test_file, + shutil.copyfile(Path(__file__).parent / 'data' / font_test_file, user_fonts_dir.join(font_test_file)) with monkeypatch.context() as m: @@ -181,7 +181,7 @@ def test_user_fonts_linux(tmpdir, monkeypatch): def test_addfont_as_path(): """Smoke test that addfont() accepts pathlib.Path.""" font_test_file = 'mpltest.ttf' - path = Path(__file__).parent / font_test_file + path = Path(__file__).parent / 'data' / font_test_file try: fontManager.addfont(path) added, = (font for font in fontManager.ttflist @@ -215,7 +215,7 @@ def test_user_fonts_win32(): os.makedirs(user_fonts_dir) # Copy the test font to the user font directory - shutil.copy(Path(__file__).parent / font_test_file, user_fonts_dir) + shutil.copy(Path(__file__).parent / 'data' / font_test_file, user_fonts_dir) # Now, the font should be available fonts = findSystemFonts() diff --git a/lib/matplotlib/tests/test_mathtext.py b/lib/matplotlib/tests/test_mathtext.py index 198e640ad286..39c28dc9228c 100644 --- a/lib/matplotlib/tests/test_mathtext.py +++ b/lib/matplotlib/tests/test_mathtext.py @@ -437,7 +437,7 @@ def test_mathtext_fallback_invalid(): ("stix", ['DejaVu Sans', 'mpltest', 'STIXGeneral', 'STIXGeneral', 'STIXGeneral'])]) def test_mathtext_fallback(fallback, fontlist): mpl.font_manager.fontManager.addfont( - str(Path(__file__).resolve().parent / 'mpltest.ttf')) + (Path(__file__).resolve().parent / 'data/mpltest.ttf')) mpl.rcParams["svg.fonttype"] = 'none' mpl.rcParams['mathtext.fontset'] = 'custom' mpl.rcParams['mathtext.rm'] = 'mpltest' diff --git a/lib/matplotlib/tests/test_sphinxext.py b/lib/matplotlib/tests/test_sphinxext.py index 1aaa6baca47c..6e42378bdf6b 100644 --- a/lib/matplotlib/tests/test_sphinxext.py +++ b/lib/matplotlib/tests/test_sphinxext.py @@ -13,6 +13,9 @@ pytest.importorskip('sphinx', minversion='4.1.3') +tinypages = Path(__file__).parent / 'data/tinypages' + + def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None): # Build the pages with warnings turned into errors extra_args = [] if extra_args is None else extra_args @@ -33,15 +36,13 @@ def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None): def test_tinypages(tmp_path): - shutil.copytree(Path(__file__).parent / 'tinypages', tmp_path, - dirs_exist_ok=True) + shutil.copytree(tinypages, tmp_path, dirs_exist_ok=True) html_dir = tmp_path / '_build' / 'html' img_dir = html_dir / '_images' doctree_dir = tmp_path / 'doctrees' # Build the pages with warnings turned into errors cmd = [sys.executable, '-msphinx', '-W', '-b', 'html', - '-d', str(doctree_dir), - str(Path(__file__).parent / 'tinypages'), str(html_dir)] + '-d', str(doctree_dir), str(tinypages), str(html_dir)] # On CI, gcov emits warnings (due to agg headers being included with the # same name in multiple extension modules -- but we don't care about their # coverage anyways); hide them using GCOV_ERROR_FILE. @@ -125,9 +126,8 @@ def plot_directive_file(num): def test_plot_html_show_source_link(tmp_path): - parent = Path(__file__).parent - shutil.copyfile(parent / 'tinypages/conf.py', tmp_path / 'conf.py') - shutil.copytree(parent / 'tinypages/_static', tmp_path / '_static') + shutil.copyfile(tinypages / 'conf.py', tmp_path / 'conf.py') + shutil.copytree(tinypages / '_static', tmp_path / '_static') doctree_dir = tmp_path / 'doctrees' (tmp_path / 'index.rst').write_text(""" .. plot:: @@ -150,9 +150,8 @@ def test_plot_html_show_source_link(tmp_path): def test_show_source_link_true(tmp_path, plot_html_show_source_link): # Test that a source link is generated if :show-source-link: is true, # whether or not plot_html_show_source_link is true. - parent = Path(__file__).parent - shutil.copyfile(parent / 'tinypages/conf.py', tmp_path / 'conf.py') - shutil.copytree(parent / 'tinypages/_static', tmp_path / '_static') + shutil.copyfile(tinypages / 'conf.py', tmp_path / 'conf.py') + shutil.copytree(tinypages / '_static', tmp_path / '_static') doctree_dir = tmp_path / 'doctrees' (tmp_path / 'index.rst').write_text(""" .. plot:: @@ -170,9 +169,8 @@ def test_show_source_link_true(tmp_path, plot_html_show_source_link): def test_show_source_link_false(tmp_path, plot_html_show_source_link): # Test that a source link is NOT generated if :show-source-link: is false, # whether or not plot_html_show_source_link is true. - parent = Path(__file__).parent - shutil.copyfile(parent / 'tinypages/conf.py', tmp_path / 'conf.py') - shutil.copytree(parent / 'tinypages/_static', tmp_path / '_static') + shutil.copyfile(tinypages / 'conf.py', tmp_path / 'conf.py') + shutil.copytree(tinypages / '_static', tmp_path / '_static') doctree_dir = tmp_path / 'doctrees' (tmp_path / 'index.rst').write_text(""" .. plot:: @@ -187,8 +185,7 @@ def test_show_source_link_false(tmp_path, plot_html_show_source_link): def test_srcset_version(tmp_path): - shutil.copytree(Path(__file__).parent / 'tinypages', tmp_path, - dirs_exist_ok=True) + shutil.copytree(tinypages, tmp_path, dirs_exist_ok=True) html_dir = tmp_path / '_build' / 'html' img_dir = html_dir / '_images' doctree_dir = tmp_path / 'doctrees' diff --git a/lib/matplotlib/tests/test_type1font.py b/lib/matplotlib/tests/test_type1font.py index 9b8a2d1f07c6..b2f93ef28a26 100644 --- a/lib/matplotlib/tests/test_type1font.py +++ b/lib/matplotlib/tests/test_type1font.py @@ -5,7 +5,7 @@ def test_Type1Font(): - filename = os.path.join(os.path.dirname(__file__), 'cmr10.pfb') + filename = os.path.join(os.path.dirname(__file__), 'data', 'cmr10.pfb') font = t1f.Type1Font(filename) slanted = font.transform({'slant': 1}) condensed = font.transform({'extend': 0.5}) @@ -78,7 +78,7 @@ def test_Type1Font(): def test_Type1Font_2(): - filename = os.path.join(os.path.dirname(__file__), + filename = os.path.join(os.path.dirname(__file__), 'data', 'Courier10PitchBT-Bold.pfb') font = t1f.Type1Font(filename) assert font.prop['Weight'] == 'Bold' @@ -137,7 +137,7 @@ def test_tokenize_errors(): def test_overprecision(): # We used to output too many digits in FontMatrix entries and # ItalicAngle, which could make Type-1 parsers unhappy. - filename = os.path.join(os.path.dirname(__file__), 'cmr10.pfb') + filename = os.path.join(os.path.dirname(__file__), 'data', 'cmr10.pfb') font = t1f.Type1Font(filename) slanted = font.transform({'slant': .167}) lines = slanted.parts[0].decode('ascii').splitlines() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy