Description
Since #11123 switched from the old-style hook wrappers to the new-style hook wrappers, I'm getting an error in the pytest-mpl
plugin tests when testing with pytest's main
branch installed. If I upgrade pytest-mpl
to use the new-style hook wrappers in its pytest_runtest_call
, the error goes away. I thought I would log the issue here in case it will cause wider issues when pytest 8 is released.
I'm seeing this: https://github.com/matplotlib/pytest-mpl/actions/runs/7233619388/job/19709093922#step:10:4021
> warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E pytest.PytestUnraisableExceptionWarning: Exception ignored in: <generator object LoggingPlugin.pytest_runtest_call at 0x7ff0fdef4ba0>
E
E Traceback (most recent call last):
E File "/home/runner/work/pytest-mpl/pytest-mpl/.tox/py312-test-mpldev-pytestdev/lib/python3.12/site-packages/_pytest/logging.py", line 813, in _runtest_for
E yield
E GeneratorExit
E
E During handling of the above exception, another exception occurred:
E
E Traceback (most recent call last):
E File "/home/runner/work/pytest-mpl/pytest-mpl/.tox/py312-test-mpldev-pytestdev/lib/python3.12/site-packages/_pytest/logging.py", line 830, in pytest_runtest_call
E yield from self._runtest_for(item, "call")
E File "/home/runner/work/pytest-mpl/pytest-mpl/.tox/py312-test-mpldev-pytestdev/lib/python3.12/site-packages/_pytest/logging.py", line 815, in _runtest_for
E log = report_handler.stream.getvalue().strip()
E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E ValueError: I/O operation on closed file
I can't really find a minimal example as the failure appears in different tests between test runs and it usually only occurs when I run the full test suite. I thought it might be related to pytester but then I saw it occurring in some non-pytester tests.
To be clear, if I checkout b41acae in the tests they fail, but if I checkout the previous commit they pass. I'm not sure where to look to isolate the issue, but maybe someone who knows the pytest codebase better would.
I think I'll upgrade pytest-mpl
to use the new-style hook wrappers. Would you recommend using the new style if pytest>=8
or if pluggy>=1.2
? Thanks 🙂
$ pip freeze
contourpy==1.2.0
coverage==7.3.3
cycler==0.12.1
fonttools==4.46.0
iniconfig==2.0.0
Jinja2==3.1.2
kiwisolver==1.4.5
MarkupSafe==2.1.3
matplotlib==3.9.0.dev0
numpy==1.26.2
packaging==23.2
Pillow==10.1.0
pluggy==1.3.0
pyparsing==3.1.1
pytest @ git+https://github.com/pytest-dev/pytest.git@047ba83dabe492af938104fe0058597f67a672be
pytest-cov==4.1.0
pytest-mpl @ file:///home/runner/work/pytest-mpl/pytest-mpl/.tox/.tmp/package/1/pytest-mpl-0.16.2.dev112%2Bgf52143a.tar.gz#sha256=e8c5423fdcfede0d588a2e634c2dd9224203f45be766d6fce48632a7fde76732
python-dateutil @ git+https://github.com/dateutil/dateutil.git@0586f4afa26fc6799128d98d4f97a49c7d6ab314
six==1.16.0