8000 TST: Use importlib for importing in pytest · matplotlib/matplotlib@243e307 · GitHub
[go: up one dir, main page]

Skip to content

Commit 243e307

Browse files
committed
TST: Use importlib for importing in pytest
This fixes the rewriting so that we get detailed variable information again, which was broken with the move to Meson (which does weird import hacking for editable installs.)
1 parent d3d3eab commit 243e307

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

.github/workflows/cygwin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ jobs:
242242
shell: bash.exe -eo pipefail -o igncr "{0}"
243243
id: cygwin-run-pytest
244244
run: |
245-
xvfb-run python -mpytest -raR -n auto \
245+
xvfb-run pytest -raR -n auto \
246246
--maxfail=50 --timeout=300 --durations=25 \
247247
--cov-report=xml --cov=lib --log-level=DEBUG --color=yes
248248

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ jobs:
316316

317317
- name: Run pytest
318318
run: |
319-
python -mpytest -raR -n auto \
319+
pytest -raR -n auto \
320320
--maxfail=50 --timeout=300 --durations=25 \
321321
--cov-report=xml --cov=lib --log-level=DEBUG --color=yes
322322

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ stages:
225225
fi
226226
echo "##vso[task.setvariable variable=VS_COVERAGE_TOOL]$TOOL"
227227
fi
228-
PYTHONFAULTHANDLER=1 python -m pytest -raR -n 2 \
228+
PYTHONFAULTHANDLER=1 pytest -raR -n 2 \
229229
--maxfail=50 --timeout=300 --durations=25 \
230230
--junitxml=junit/test-results.xml --cov-report=xml --cov=lib ||
231231
[[ "$PYTHON_VERSION" = 'Pre' ]]

doc/api/prev_api_changes/api_changes_3.5.0/deprecations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ is thus deprecated as well.
353353
To test an installed copy, be sure to specify both ``matplotlib`` and
354354
``mpl_toolkits`` with ``--pyargs``::
355355

356-
python -m pytest --pyargs matplotlib.tests mpl_toolkits.tests
356+
pytest --pyargs matplotlib.tests mpl_toolkits.tests
357357

358358
See :ref:`testing` for more details.
359359

doc/api/prev_api_changes/api_changes_3.7.0/removals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ is thus removed as well.
185185
To test an installed copy, be sure to specify both ``matplotlib`` and
186186
``mpl_toolkits`` with ``--pyargs``::
187187

188-
python -m pytest --pyargs matplotlib.tests mpl_toolkits.tests
188+
pytest --pyargs matplotlib.tests mpl_toolkits.tests
189189

190190
See :ref:`testing` for more details.
191191

doc/devel/testing.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Running the tests
3737

3838
In the root directory of your development repository run::
3939

40-
python -m pytest
40+
pytest
4141

4242

4343
pytest can be configured via a lot of `command-line parameters`_. Some
@@ -302,11 +302,18 @@ is necessary for testing ``mpl_toolkits``.
302302

303303
Run the tests
304304
^^^^^^^^^^^^^
305-
To run the all the tests on your installed version of Matplotlib::
306305

307-
python -m pytest --pyargs matplotlib.tests
306+
To run all the tests on your installed version of Matplotlib::
307+
308+
pytest --pyargs matplotlib.tests
308309

309310
The test discovery scope can be narrowed to single test modules or even single
310311
functions::
311312

312-
python -m pytest --pyargs matplotlib.tests.test_simplification.py::test_clipping
313+
pytest --pyargs matplotlib.tests.test_simplification.py::test_clipping
314+
315+
If you want to use pytest as a module, then you will need to set its import mode to the
316+
older ``prepend`` mode (this is because ``python -m`` will add the current directory to
317+
``PYTHONPATH`` causing conflicts within pytest)::
318+
319+
python -m pytest --import-mode prepend

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,6 @@ ignore_messages = [
298298
# `lib/matplotlib/testing/conftest.py`.
299299
minversion = "7.0"
300300
testpaths = ["lib"]
301+
addopts = [
302+
"--import-mode=importlib",
303+
]

0 commit comments

Comments
 (0)
0