Skip to content

Run subprocess-starting tests in a separate xdist loadgroup #30267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ jobs:
if [[ "${{ matrix.python-version }}" == '3.13t' ]]; then
export PYTHON_GIL=0
fi
pytest -rfEsXR -n auto \
pytest -rfEsXR -n auto --dist=loadgroup \
--maxfail=50 --timeout=300 --durations=25 \
--cov-report=xml --cov=lib --log-level=DEBUG --color=yes

Expand Down
3 changes: 1 addition & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ stages:
VS_VER=2022

echo "##vso[task.setvariable variable=VS_COVERAGE_TOOL]$TOOL"

PYTHONFAULTHANDLER=1 pytest -rfEsXR -n 2 \
PYTHONFAULTHANDLER=1 pytest -rfEsXR -n 2 --dist=loadgroup \
--maxfail=50 --timeout=300 --durations=25 \
--junitxml=junit/test-results.xml --cov-report=xml --cov=lib

Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/testing/_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ def _checkdep_usetex() -> bool:
needs_usetex = pytest.mark.skipif(
not _checkdep_usetex(),
reason="This test needs a TeX installation")
starts_subprocess = pytest.mark.xdist_group("subprocess")
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_backend_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import pytest

from matplotlib.testing import subprocess_run_for_testing
from matplotlib.testing._markers import starts_subprocess

nbformat = pytest.importorskip('nbformat')
pytest.importorskip('nbconvert')
pytest.importorskip('ipykernel')
pytest.importorskip('matplotlib_inline')
pytestmark = starts_subprocess

Check warning on line 14 in lib/matplotlib/tests/test_backend_inline.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/tests/test_backend_inline.py#L14

Added line #L14 was not covered by tests


def test_ipynb():
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
from tempfile import TemporaryDirectory

import pytest
from matplotlib.testing._markers import starts_subprocess

from matplotlib.testing import subprocess_run_for_testing

nbformat = pytest.importorskip('nbformat')
pytest.importorskip('nbconvert')
pytest.importorskip('ipykernel')
pytestmark = starts_subprocess

Check warning on line 13 in lib/matplotlib/tests/test_backend_nbagg.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/tests/test_backend_nbagg.py#L13

Added line #L13 was not covered by tests

# From https://blog.thedataincubator.com/2016/06/testing-jupyter-notebooks/

Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_backend_webagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import pytest

import matplotlib.backends.backend_webagg_core
from matplotlib.testing._markers import starts_subprocess
from matplotlib.testing import subprocess_run_for_testing


@starts_subprocess
@pytest.mark.parametrize("backend", ["webagg", "nbagg"])
def test_webagg_fallback(backend):
pytest.importorskip("tornado")
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/tests/test_backends_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
from matplotlib import _c_internal_utils
from matplotlib.backend_tools import ToolToggleBase
from matplotlib.testing import subprocess_run_helper as _run_helper, is_ci_environment
from matplotlib.testing._markers import starts_subprocess


pytestmark = starts_subprocess


class _WaitForStringPopen(subprocess.Popen):
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import textwrap

from matplotlib.testing._markers import starts_subprocess
from matplotlib.testing import subprocess_run_for_testing


Expand All @@ -28,6 +29,7 @@ def test_override_builtins():
assert overridden <= ok_to_override


@starts_subprocess
def test_lazy_imports():
source = textwrap.dedent("""
import sys
Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/tests/test_determinism.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
from matplotlib.patches import Circle, PathPatch
from matplotlib.path import Path
from matplotlib.testing import subprocess_run_for_testing
from matplotlib.testing._markers import needs_ghostscript, needs_usetex
from matplotlib.testing._markers import (
needs_ghostscript, needs_usetex, starts_subprocess
)
import matplotlib.testing.compare
from matplotlib.text import TextPath
from matplotlib.transforms import IdentityTransform

pytestmark = starts_subprocess


def _save_figure(objects='mhip', fmt="pdf", usetex=False):
mpl.use(fmt)
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
MSUserFontDirectories, _get_fontconfig_fonts, ttfFontProperty)
from matplotlib import cbook, ft2font, pyplot as plt, rc_context, figure as mfigure
from matplotlib.testing import subprocess_run_helper, subprocess_run_for_testing
from matplotlib.testing._markers import starts_subprocess


has_fclist = shutil.which('fc-list') is not None
Expand Down Expand Up @@ -288,6 +289,7 @@ def test_fontcache_thread_safe():
subprocess_run_helper(_test_threading, timeout=10)


@starts_subprocess
def test_lockfilefailure(tmp_path):
# The logic here:
# 1. get a temp directory from pytest
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/tests/test_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import matplotlib
from matplotlib.testing import subprocess_run_for_testing
from matplotlib.testing._markers import starts_subprocess


@pytest.mark.parametrize('version_str, version_tuple', [
Expand All @@ -19,6 +20,7 @@ def test_parse_to_version_info(version_str, version_tuple):
assert matplotlib._parse_to_version_info(version_str) == version_tuple


@starts_subprocess
@pytest.mark.skipif(sys.platform == "win32",
reason="chmod() doesn't work as is on Windows")
@pytest.mark.skipif(sys.platform != "win32" and os.geteuid() == 0,
Expand All @@ -37,6 +39,7 @@ def test_tmpconfigdir_warning(tmp_path):
os.chmod(tmp_path, mode)


@starts_subprocess
def test_importable_with_no_home(tmp_path):
subprocess_run_for_testing(
[sys.executable, "-c",
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/tests/test_preprocess_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from matplotlib.axes import Axes
from matplotlib.testing import subprocess_run_for_testing
from matplotlib.testing.decorators import check_figures_equal
from matplotlib.testing._markers import starts_subprocess


# Notes on testing the plotting functions itself
# * the individual decorated plotting functions are tested in 'test_axes.py'
Expand Down Expand Up @@ -245,6 +247,7 @@ def funcy(ax, x, y, z, t=None):
funcy.__doc__)


@starts_subprocess
def test_data_parameter_replacement():
"""
Test that the docstring contains the correct *data* parameter stub
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/tests/test_pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
from matplotlib.testing import subprocess_run_for_testing
from matplotlib import pyplot as plt

from matplotlib.testing._markers import starts_subprocess


@starts_subprocess
def test_pyplot_up_to_date(tmp_path):
pytest.importorskip("black")

Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
_validate_linestyle,
_listify_validator)
from matplotlib.testing import subprocess_run_for_testing
from matplotlib.testing._markers import starts_subprocess


def test_rcparams(tmp_path):
Expand Down Expand Up @@ -528,6 +529,7 @@ def test_rcparams_reset_after_fail():
assert mpl.rcParams['text.usetex'] is False


@starts_subprocess
@pytest.mark.skipif(sys.platform != "linux", reason="Linux only")
def test_backend_fallback_headless_invalid_backend(tmp_path):
env = {**os.environ,
Expand All @@ -545,6 +547,7 @@ def test_backend_fallback_headless_invalid_backend(tmp_path):
env=env, check=True, stderr=subprocess.DEVNULL)


@starts_subprocess
@pytest.mark.skipif(sys.platform != "linux", reason="Linux only")
def test_backend_fallback_headless_auto_backend(tmp_path):
# specify a headless mpl environment, but request a graphical (tk) backend
Expand All @@ -567,6 +570,7 @@ def test_backend_fallback_headless_auto_backend(tmp_path):
assert backend.strip().lower() == "agg"


@starts_subprocess
@pytest.mark.skipif(
sys.platform == "linux" and not _c_internal_utils.xdisplay_is_valid(),
reason="headless")
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/tests/test_sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import sys

from matplotlib.testing import subprocess_run_for_testing
from matplotlib.testing._markers import starts_subprocess

import pytest


Expand All @@ -16,6 +18,7 @@
tinypages = Path(__file__).parent / 'data/tinypages'


@starts_subprocess
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
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from matplotlib.testing import subprocess_run_for_testing
from matplotlib.testing._markers import needs_usetex
from matplotlib.texmanager import TexManager
from matplotlib.testing._markers import starts_subprocess


def test_fontconfig_preamble():
Expand Down Expand Up @@ -63,6 +64,7 @@ def test_unicode_characters():
fig.canvas.draw()


@starts_subprocess
@needs_usetex
def test_openin_any_paranoid():
completed = subprocess_run_for_testing(
Expand Down
Loading